fix: edit history 'after' showed original content, not edited content

getRecentEdits SELECT ... m.content AS new_content returned the message's
ORIGINAL content (never updated on edit) instead of the post-edit content.
messages.content stores the original body; the current/last-edited body lives
in messages.edited_content. So before===after in the Message Edits diff.

Fix: COALESCE(m.edited_content, m.content) AS new_content so 'After' shows the
edited text and diffs against the captured before-content are meaningful.
This commit is contained in:
asepharyana
2026-08-27 17:28:24 +07:00
parent 631b5e1027
commit 5196cb0221
@@ -503,7 +503,7 @@ export class MessagesRepository {
m.channel_id, m.channel_id,
COALESCE(NULLIF((m.metadata::jsonb -> 'channel' ->> 'channelName'), ''), m.channel_id) AS channel_name, COALESCE(NULLIF((m.metadata::jsonb -> 'channel' ->> 'channelName'), ''), m.channel_id) AS channel_name,
m.username, m.username,
m.content AS new_content COALESCE(m.edited_content, m.content) AS new_content
FROM message_edits e FROM message_edits e
JOIN messages m ON m.id = e.message_id JOIN messages m ON m.id = e.message_id
${channelId ? sql`WHERE m.channel_id = ${channelId}` : sql``} ${channelId ? sql`WHERE m.channel_id = ${channelId}` : sql``}