2.7 KiB
2.7 KiB
Signal reaction notifications ("own" mode) investigation
Context
- Code path:
src/signal/monitor.tshandles reaction-only envelopes and callsenqueueSystemEvent. - Default mode is "own" in config, which should notify when someone reacts to a message authored by the bot account.
Findings
- Signal reaction handling only runs when
envelope.reactionMessageis present anddataMessageis absent. If signal-cli includesreactionMessagealongsidedataMessage, the reaction is ignored because the handler only runs in thereactionMessage && !dataMessagebranch. resolveSignalReactionTarget()preferstargetAuthorUuidovertargetAuthor. If signal-cli includes both (common for sender identity fields), the target becomeskind: "uuid", even when a phone number is also present.- In "own" mode,
shouldEmitSignalReactionNotification()compares the configuredsignal.accountstring against the target. With a phone-configured account (e.g.,+14154668323) and a UUID target, the check fails. - The tests in
src/signal/monitor.tool-result.test.tsonly cover reaction payloads withtargetAuthor(phone), so UUID-first handling is not exercised. - Discord "own" mode compares
messageAuthorIdtobotUserId(shouldEmitDiscordReactionNotification), which is strictly an ID match. The Signal implementation mirrors this pattern, but the target identity type mismatch (UUID vs E.164) breaks the comparison.
Likely root cause
- Signal-cli reaction payloads appear to include
targetAuthorUuideven whentargetAuthor(phone) is present. BecauseresolveSignalReactionTarget()always prefers UUID, "own" mode never matches whensignal.accountis configured as E.164, causing no notification.
Secondary risk
- If signal-cli includes
reactionMessagealongsidedataMessage(instead of reaction-only envelopes), the current handler never emits system events for reactions.
Debug logging to confirm (if needed)
- Add a verbose log around the reaction handler to capture the identity fields and decision:
targetAuthor,targetAuthorUuid, computedtarget.kind/id,account,mode, andshouldNotify.- Log when
reactionMessageis present butdataMessageis also present to verify whether reactions arrive as combined payloads.
Suggested fixes (not applied)
- When mode is "own", compare the configured account against both
targetAuthor(normalized E.164) andtargetAuthorUuid, rather than selecting UUID first. - Or, in
resolveSignalReactionTarget(), if both values exist and the configured account is a phone number, prefertargetAuthorover UUID for the "own" check. - Consider emitting reaction notifications even if
reactionMessageanddataMessagecoexist (guarded to avoid double-processing).