matrix-appservice-discord icon indicating copy to clipboard operation
matrix-appservice-discord copied to clipboard

Multiple discord edits of the same message are buggy

Open dzaima opened this issue 2 years ago • 1 comments

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

  1. Post a discord message
  2. Edit the discord message
  3. Edit the same message again
  4. 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 MatrixIds.

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)

dzaima avatar Jun 06 '22 20:06 dzaima

Related: https://github.com/vector-im/element-web/issues/16722

Thanks for finding the root cause of this!

mrjohnson22 avatar Jun 07 '22 03:06 mrjohnson22