Skip to content

fix(desktop): tag reaction events with the target author's pubkey (#2568) - #4375

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/2568-reaction-p-tag
Open

iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/2568-reaction-p-tag

Conversation

@iroiro147

Copy link
Copy Markdown
Contributor

What

Fixes #2568 — reaction events (NIP-25 kind 7) only carried an e tag for the target event, so relay-side notification filters keyed on #p never matched them. Adds the target event's author as a p tag.

Change

Scoped to the desktop persistent-reaction path (the exact case in the issue's repro — a user reacting to a message):

  • events::build_reaction — accept an optional target_author_pubkey and emit ["p", author] when present. On a None author the tag is omitted and the submit still succeeds.
  • add_reaction — resolve the target event's author with a single query_relay lookup (same pattern as the adjacent remove_reaction), then pass it to the builder. Any lookup failure degrades to a no-p-tag reaction rather than an error. When the reactor is the target author, nostr's build-step correctly drops the self-referential p tag (you don't notify yourself).

Out of scope (deliberate)

The ephemeral ACP cosmetic reactions (👀/💬 flash reactions) and the CLI reaction path are unchanged — they are separate surfaces, and the issue's repro is specifically the user's desktop reaction. Widening those is a follow-up if wanted.

Verification

  • cargo test events::57 pass, incl. 2 new tests:
    • reaction_carries_target_author_p_tag_when_known
    • reaction_omits_p_tag_when_author_unknown
  • cargo check — clean
  • cargo fmt --check — clean

Signed-off-by: Sarthak Singh sarthak.singh@juspay.in

…ock#2568)

Reaction events (NIP-25 kind 7) carried only an `e` tag for the target
event, so relay-side notification filters keyed on `#p` never matched them.
This adds the target event's author as a `p` tag.

- `events::build_reaction`: accept an optional `target_author_pubkey` and
  emit a `["p", author]` tag when present (degrade: omit the tag, never
  fail the submit).
- `add_reaction`: resolve the target event's author via a single
  `query_relay` lookup (same pattern as `remove_reaction`), then pass it
  through. On any lookup failure the reaction still submits without the
  tag. When the reactor IS the target author, nostr's build-step correctly
  drops the self-referential `p` tag.

Scope: desktop persistent-reaction path only. The ephemeral ACP cosmetic
reactions (👀/💬) and the CLI path are deliberately out of scope.

Verified: cargo test events:: (57 pass, incl. 2 new p-tag tests), cargo
check clean, cargo fmt clean.

Signed-off-by: Sarthak Singh <sarthak.singh@juspay.in>
@iroiro147
iroiro147 requested a review from a team as a code owner August 2, 2026 18:14
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.

[Bug] Reactions without p-tags

1 participant