Skip to content

fix(workflow): implement AddReaction via NIP-25 sink; resolve reaction trigger context from target event - #6508

Closed
hakeemmukif wants to merge 2 commits into
block:mainfrom
hakeemmukif:fix/workflow-reaction-and-trigger-context
Closed

fix(workflow): implement AddReaction via NIP-25 sink; resolve reaction trigger context from target event#6508
hakeemmukif wants to merge 2 commits into
block:mainfrom
hakeemmukif:fix/workflow-reaction-and-trigger-context

Conversation

@hakeemmukif

Copy link
Copy Markdown

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_reaction trait 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 CLI reactions add works. No new REST route.

Bug 2 — reaction trigger context described the wrong event

{{ trigger.text }} on a reaction trigger rendered 1f50d (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's e tag and overwrites text/author/channel fields from the target event, falling back to reaction fields if lookup fails.

Also

  • Removed dead add_reaction_impl + unused helpers.
  • tenant normalize_host: accept loopback variants for tenants seeded as localhost (Host-header binding previously failed closed).

Testing

  • cargo test -p buzz-workflow: 169/169 passing.
  • Live end-to-end on prod relay (image built from this branch): bug posted to #bugs-inbox → 🔍 reaction → run completed all 3 steps (prompt post, ⏳ reaction via new sink path, notice with correct rendered bug text).

…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.
@hakeemmukif
hakeemmukif requested a review from a team as a code owner August 21, 2026 19:04
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.
@hakeemmukif

Copy link
Copy Markdown
Author

Closing — keeping this work on my fork instead of upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant