Skip to content

Conversation

@lorenzo132
Copy link
Member

Forwarded message now will show correctly in logviewer.
image

StephenDaDev
StephenDaDev previously approved these changes Dec 5, 2025
Copy link
Member

@StephenDaDev StephenDaDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@StephenDaDev StephenDaDev added the changelog Changes in PR have been added to draft release that will be used for the changelog on the next ver. label Dec 5, 2025
Copy link

@SoAJeff SoAJeff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the quick turn-around on getting a fix for this. As a mod in a server that receives a lot of forwarded messages in Modmail threads to us, the recent additions in supporting forwarded messages both on the bot side and the logviewer side have been very helpful to us.

Just one minor correction I saw to improve usability for mods reviewing Modmail logs after the fact.

core/utils.py Outdated
Comment on lines 697 to 698
# Add source link to the container message since snapshot doesn't have its own public link
formatted_part += f"\n**Source:** {message.jump_url}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always returns a link to the forwarded message instance that is in the DM with the bot, rather than to the original message that was forwarded - which won't be accessible to the moderator reviewing the content in the logviewer.

The "Context" line when a forwarded message is sent in a Modmail ticket channel (which appears when the forwarded message location is one that the bot is able to fetch) would be a better solution here - perhaps something like what is done in thread.py

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a nice solution yea. If you are able to PR this that would be great, otherwise i will look into this either this week or next week.

lorenzo132 and others added 2 commits December 17, 2025 17:29
I believe it is a safer aproach to remove the jumpurl from logviewer, since it shows in the threadchannel already.
StephenDaDev
StephenDaDev previously approved these changes Dec 19, 2025
url = getattr(a, "url", None)
filename = getattr(a, "filename", "Unknown")
if url:
attachments.append((url.split("?")[0], filename))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's because of this PR, but forwarded attachments show up incorrectly formatted in the logviewer. They show up as [image](link) and don't properly embed. An image sent directly does show up properly.

Image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been able to partialy resolve this request. Images would show as following for some reason.
image

Copilot AI review requested due to automatic review settings December 27, 2025 02:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the display of forwarded messages in the logviewer by properly extracting and formatting forwarded message content and attachments from Discord's message snapshots API.

Key changes:

  • Added extract_forwarded_attachments() utility function to extract attachment URLs from forwarded messages
  • Refactored extract_forwarded_content() to improve formatting with better visual indicators and proper URL embedding for the logviewer
  • Integrated forwarded content and attachment extraction across message handling flows (thread creation, logging, and message sending)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
core/utils.py Added extract_forwarded_attachments() function and refactored extract_forwarded_content() to improve formatting with emoji indicators, remove author attribution (due to API limitations), and extract attachment URLs for proper logviewer embedding
core/thread.py Integrated forwarded content extraction in snooze message serialization and added forwarded attachment extraction in the send method to ensure forwarded attachments are properly displayed
core/clients.py Added forwarded content extraction in append_log() to merge forwarded message content with regular message content for logging
bot.py Extended ForwardedMessage class to include attachments from message snapshots, ensuring forwarded attachments are preserved when creating thread messages
Comments suppressed due to low confidence (1)

core/clients.py:697

  • The append_log function in clients.py extracts forwarded content but doesn't include forwarded attachments in the attachments list. This creates an inconsistency where forwarded attachments are handled in thread.py (lines 1963-1965) but not here. Consider also extracting and appending forwarded attachments to ensure they appear in the log:
from core.utils import extract_forwarded_content, extract_forwarded_attachments

# ... existing code ...

# After getting regular attachments, also get forwarded attachments
forwarded_attachments = extract_forwarded_attachments(message)

This would ensure that forwarded message attachments are properly logged and displayed in the logviewer.

            "attachments": [
                {
                    "id": a.id,
                    "filename": a.filename,
                    "is_image": a.width is not None,
                    "size": a.size,
                    "url": a.url,
                }
                for a in message.attachments
            ],

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@modmail-dev modmail-dev deleted a comment from Copilot AI Dec 27, 2025
@modmail-dev modmail-dev deleted a comment from Copilot AI Dec 27, 2025
@modmail-dev modmail-dev deleted a comment from Copilot AI Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog Changes in PR have been added to draft release that will be used for the changelog on the next ver.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attachment support for forwarded messages Support editing and deleting plain messages

5 participants