fix(workflow): implement AddReaction via NIP-25 sink; resolve reaction trigger context from target event - #6508
Closed
hakeemmukif wants to merge 2 commits into
Closed
Conversation
…n trigger context from target event
- AddReaction previously called POST /api/messages/{id}/reactions, a route
that never existed in the relay — every attempt failed with 404. Replace
with a proper ActionSink::add_reaction: the relay signs and persists a
real kind:7 NIP-25 reaction through the standard ingest/fan-out path.
- Reaction triggers now resolve the reacted-to message via the e tag so
{{ trigger.text }} / {{ trigger.author }} describe the bug report, not
the reaction event itself.
- Remove dead add_reaction_impl and unused helpers.
- tenant normalize_host: accept loopback variants (127.0.0.1) for tenants
seeded as localhost, fixing Host-header binding fail-closed.
buzz-workflow tests: 169/169 passing.
Relay-authored events (workflow notifications, moderation notices) showed as truncated pubkeys in clients because the relay had no kind:0 profile. Publish an idempotent replaceable metadata event for the relay's own pubkey during startup; name configurable via BUZZ_RELAY_PROFILE_NAME (default 'buzz-relay'). Also expose dispatch_persistent_event for reuse outside handlers::event.
Author
|
Closing — keeping this work on my fork instead of upstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related workflow-engine bugs fixed; both verified live against the production relay.
Bug 1 — AddReaction targeted a nonexistent route
The executor called
POST /api/messages/{id}/reactions, a route absent from the relay's entire router. Every AddReaction step failed with 404 (this was never working in any deployment — nearby tells: the// TODO (WF-07)in SendDm, NotImplemented SetChannelTopic).Fix: new
ActionSink::add_reactiontrait method. The relay-side impl builds a genuine NIP-25 kind:7 event, signs it with the relay keypair, and pushes it through the existing persist/fan-out ingest path — mirroring how CLIreactions addworks. No new REST route.Bug 2 — reaction trigger context described the wrong event
{{ trigger.text }}on a reaction trigger rendered1f50d(the emoji code) because the context builder never resolved the reacted-to message.Fix:
WorkflowEngine(which holds db access) now resolves the target via the reaction'setag and overwrites text/author/channel fields from the target event, falling back to reaction fields if lookup fails.Also
add_reaction_impl+ unused helpers.normalize_host: accept loopback variants for tenants seeded aslocalhost(Host-header binding previously failed closed).Testing
cargo test -p buzz-workflow: 169/169 passing.