Don't delete our reaction on Discord unless we have 0 of that reaction coming from Matrix #85

Open
ellie wants to merge 8 commits from ellie/out-of-your-element:ellie-fix-reacts into main
First-time contributor

Fixes a bug where, if multiple Matrix users had used the same reaction on a message, and then one of those Matrix users removed their reactions, the bot would forcibly remove all of that reactions. Now, we check and make sure there are no remaining reactions from Matrix before removal.

Fixes a bug where, if multiple Matrix users had used the same reaction on a message, and then one of those Matrix users removed their reactions, the bot would forcibly remove all of that reactions. Now, we check and make sure there are no remaining reactions from Matrix before removal.
ellie added 1 commit 2026-04-04 23:47:13 +00:00
ellie reviewed 2026-04-04 23:59:54 +00:00
ellie left a comment
Author
First-time contributor

Self-review. I don't think anything else needs to be done here (or would make sense to include).

Self-review. I don't think anything else needs to be done here (or would make sense to include).
cadence added 1 commit 2026-04-05 01:31:45 +00:00
cadence added 1 commit 2026-04-05 03:06:13 +00:00
ellie added 1 commit 2026-04-05 08:26:40 +00:00
cadence reviewed 2026-04-05 15:03:34 +00:00
cadence left a comment
Owner

Just a quick look. Seems like the right path! Thanks for humouring me.

Just a quick look. Seems like the right path! Thanks for humouring me.
@ -57,6 +59,30 @@ function eventNotFoundThenRetrigger(inputID, fn, ...rest) {
return true // event was not found, then retrigger
}
function reactionNotFoundThenRetrigger(reactionEventID, fn, ...rest){
Owner

Is it more or less gross if these were abstracted into a common base?

Is it more or less gross if these were abstracted into a common base?
Owner

It was less gross

It was less gross
cadence marked this conversation as resolved
@ -51,2 +51,4 @@
db.prepare("REPLACE INTO reaction (hashed_event_id, message_id, encoded_emoji, original_encoding) VALUES (?, ?, ?, ?)").run(utils.getEventIDHash(event.event_id), messageID, discordPreferredEncoding, key)
retrigger.messageFinishedBridging(event.event_id)
Owner

Is this really the correct function to call here?

Is this really the correct function to call here?
cadence marked this conversation as resolved
@ -41,11 +41,17 @@ async function suppressEmbeds(event) {
* @param {Ty.Event.Outer_M_Room_Redaction} event
*/
async function removeReaction(event) {
if (retrigger.reactionNotFoundThenRetrigger(event.redacts, () => as.emit("type:m.room.redaction", event))) return
Owner

Retrigger target should be this function, not as.emit, otherwise other operations related to redaction could possibly be duplicated

Retrigger target should be this function, not as.emit, otherwise other operations related to redaction could possibly be duplicated
cadence marked this conversation as resolved
ellie added 1 commit 2026-04-09 04:03:05 +00:00
ellie added 1 commit 2026-04-09 04:11:06 +00:00
Author
First-time contributor

Note: after this is merged see if the ourDeletedReactions array fills up with garbage data, or if it's reliably removing stuff added to it (we don't currently clear this).

Sometimes there's only an emoji ID, apparently? We should handle this properly.

Note: after this is merged see if the `ourDeletedReactions` array fills up with garbage data, or if it's reliably removing stuff added to it (we don't currently clear this). Sometimes there's only an emoji ID, apparently? We should handle this properly.
ellie added 1 commit 2026-04-09 05:26:15 +00:00
ellie added 1 commit 2026-04-09 05:28:14 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u ellie-fix-reacts:ellie-ellie-fix-reacts
git checkout ellie-ellie-fix-reacts

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout main
git merge --no-ff ellie-ellie-fix-reacts
git checkout ellie-ellie-fix-reacts
git rebase main
git checkout main
git merge --ff-only ellie-ellie-fix-reacts
git checkout ellie-ellie-fix-reacts
git rebase main
git checkout main
git merge --no-ff ellie-ellie-fix-reacts
git checkout main
git merge --squash ellie-ellie-fix-reacts
git checkout main
git merge --ff-only ellie-ellie-fix-reacts
git checkout main
git merge ellie-ellie-fix-reacts
git push origin main
Sign in to join this conversation.
No description provided.