fix(federation): fix reaction relay using wrong ID for message lookup
Reaction outbox events used reactionId (add) or a composite dedup key (remove) as the event messageId. The receiver looked up dm_messages by sourceMessageId = event.messageId, which never matched because it was searching for a reactionId, not the actual message ID. Fix: include the actual DM messageId in the reaction payload JSON. The receiver now uses event.reaction.messageId for the lookup, with fallback to event.messageId for backward compatibility.
This commit is contained in:
@@ -1252,14 +1252,16 @@ function processReactionAddEvent(
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the local message corresponding to the source message
|
||||
// Find the local message — use the actual message ID from the reaction payload,
|
||||
// not event.messageId which is the outbox dedup key (reactionId)
|
||||
const sourceMessageId = event.reaction.messageId ?? event.messageId;
|
||||
const localMsg = db
|
||||
.select()
|
||||
.from(schema.dmMessages)
|
||||
.where(
|
||||
and(
|
||||
eq(schema.dmMessages.sourceInstance, sourceInstance),
|
||||
eq(schema.dmMessages.sourceMessageId, event.messageId),
|
||||
eq(schema.dmMessages.sourceMessageId, sourceMessageId),
|
||||
),
|
||||
)
|
||||
.get();
|
||||
@@ -1337,14 +1339,16 @@ function processReactionRemoveEvent(
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the local message
|
||||
// Find the local message — use the actual message ID from the reaction payload,
|
||||
// not event.messageId which is the outbox dedup key (composite string)
|
||||
const sourceMessageId = event.reaction.messageId ?? event.messageId;
|
||||
const localMsg = db
|
||||
.select()
|
||||
.from(schema.dmMessages)
|
||||
.where(
|
||||
and(
|
||||
eq(schema.dmMessages.sourceInstance, sourceInstance),
|
||||
eq(schema.dmMessages.sourceMessageId, event.messageId),
|
||||
eq(schema.dmMessages.sourceMessageId, sourceMessageId),
|
||||
),
|
||||
)
|
||||
.get();
|
||||
|
||||
Reference in New Issue
Block a user