Skip to content

Commit df56b0d

Browse files
committed
fix(desktop): use the reacted-to event's signer for the NIP-25 p tag
The desktop reaction path took its `p` tag from `TimelineMessage.pubkey`, the *displayed* author that `formatTimelineMessages` resolves — which for a relay-signed agent message is rewritten from the event's `actor`/first `p` tag, not the signer. NIP-25's `p` tag is the pubkey of the event being reacted to (the signer), and every other surface in this PR (SDK, CLI, ACP, mobile) already uses the raw event author. As written, the same target event could get different `p` tags depending on which client reacted, and a delegated actor could be notified while the signer was omitted. Switch the two desktop timeline handlers to the already-retained `signerPubkey`. Pulse (`useNoteActions`) keeps `note.pubkey`: a kind:1 social note is user-signed with no delegation, so its author is the signer. Signed-off-by: Shani Singh <[email protected]>
1 parent 9c191f4 commit df56b0d

5 files changed

Lines changed: 20 additions & 16 deletions

File tree

‎desktop/src-tauri/src/commands/messages.rs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -816,12 +816,11 @@ pub async fn send_managed_agent_channel_message(
816816
})
817817
}
818818

819-
/// `target_pubkey` is the *displayed* author of the reacted-to message — the
820-
/// pubkey the timeline resolved via `resolveEventAuthorPubkey`, not the raw
821-
/// signer. For relay-signed agent messages those differ, and the person who
822-
/// should see the notification is the resolved author. Callers already hold
823-
/// this on the message they are reacting to, so it is passed in rather than
824-
/// re-derived here from a second relay round trip.
819+
/// `target_pubkey` is the signer of the reacted-to event — the pubkey NIP-25's
820+
/// `p` tag names. Callers pass the timeline's `signerPubkey` (not the resolved
821+
/// display author, which a relay-signed agent message rewrites), so the tag
822+
/// matches what every other Buzz surface emits for the same target. It is
823+
/// passed in rather than re-derived here from a second relay round trip.
825824
#[tauri::command]
826825
pub async fn add_reaction(
827826
event_id: String,

‎desktop/src/features/channels/useChannelPaneHandlers.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,18 @@ export function useChannelPaneHandlers({
327327

328328
const handleToggleReaction = React.useCallback(
329329
async (
330-
message: { id: string; pubkey?: string },
330+
message: { id: string; signerPubkey?: string },
331331
emoji: string,
332332
remove: boolean,
333333
) => {
334334
await toggleMutateRef.current({
335335
emoji,
336336
eventId: message.id,
337337
remove,
338-
targetPubkey: message.pubkey,
338+
// NIP-25's `p` tag is the signer of the reacted-to event, not its
339+
// displayed author — a relay-signed agent message resolves those to
340+
// different pubkeys, and the protocol tag must be the signer.
341+
targetPubkey: message.signerPubkey,
339342
});
340343
},
341344
[],

‎desktop/src/features/home/ui/HomeView.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,8 @@ export function HomeView({
921921
emoji,
922922
eventId: message.id,
923923
remove,
924-
targetPubkey: message.pubkey,
924+
// NIP-25 `p` tag is the reacted-to event's signer.
925+
targetPubkey: message.signerPubkey,
925926
});
926927
await threadContext.refreshReactions();
927928
await channelMessagesQuery.refetch();

‎desktop/src/features/messages/hooks.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,9 @@ export function useToggleReactionMutation() {
644644
emoji: string;
645645
remove: boolean;
646646
/**
647-
* Resolved author of the message being reacted to. Becomes the kind:7
648-
* NIP-25 `p` tag so the author's notification filter can match.
647+
* Signer of the message being reacted to. Becomes the kind:7 NIP-25 `p`
648+
* tag so the author's notification filter can match. Pass the timeline's
649+
* `signerPubkey`, not its display author.
649650
*/
650651
targetPubkey: string | undefined;
651652
}
@@ -656,9 +657,9 @@ export function useToggleReactionMutation() {
656657
return;
657658
}
658659

659-
// NIP-25 requires the target author's `p` tag, so a message whose author
660-
// we could not resolve cannot produce a conformant reaction. Every
661-
// timeline row carries a resolved author, so this is a guard, not a
660+
// NIP-25 recommends the target author's `p` tag, so without a resolved
661+
// signer we would emit a reaction no notification filter can match.
662+
// Every timeline row carries a signer, so this is a guard, not a
662663
// reachable UI state.
663664
if (!targetPubkey) {
664665
throw new Error("Cannot react: the message author is unknown.");

‎desktop/src/shared/api/tauri.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ export async function deleteMessage(
636636
}
637637

638638
/**
639-
* `targetPubkey` is the resolved author of the reacted-to message. It becomes
640-
* the NIP-25 `p` tag on the kind:7, which is what lets the author find the
639+
* `targetPubkey` is the signer of the reacted-to event. It becomes the NIP-25
640+
* `p` tag on the kind:7 (a SHOULD), which is what lets the author find the
641641
* reaction with a `{"kinds":[7],"#p":[self]}` notification filter.
642642
*/
643643
export async function addReaction(

0 commit comments

Comments
 (0)