matrix-appservice-discord
matrix-appservice-discord copied to clipboard
Multiple discord edits of the same message are buggy
Multiple discord edits of the same message (sometimes?) results in the message going blank on matrix. This is because the bot "edits" the previous matrix edit event, instead of editing the original message again.
Steps
- Post a discord message
- Edit the discord message
- Edit the same message again
- View the bridged message in Element, sometimes after following the steps a blank line will be in place of the message.
Expected behavior The message is displayed as edited with the new content.
Debugging, potential fix
As far as I can tell, this is where the info about an edit is stored at, and this is where it's read. So one DiscordId
ends up corresponding to multiple MatrixId
s.
I believe a simple fix would be to change this line to evt.MatrixId = `${editEventId};${room}`;
, i.e. never store edit event IDs in the database. (or the write to the store could just be disabled for edits?)
That has the issue that matrix clients which don't support edits replying to the edit fallbacks won't be understood though.
Another option would be to get the oldest event corresponding to the discord ID, but I don't know where and how that would be done, nor whether the db even stores info to do that.
(A similar issue, with the same cause, is that a discord reply to an edited discord message ends up also replying to the edit event on matrix)
Related: https://github.com/vector-im/element-web/issues/16722
Thanks for finding the root cause of this!