From 530895b3d5478f3951cd49c24591ab4f6db5b945 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Jan 2026 12:46:07 +0000 Subject: [PATCH] fix: handle group DMs with multiple p-tags correctly Previously, conversation keys only included sender + current recipient, causing group DM messages to be split into separate 1-on-1 conversations. Now extracts ALL p-tags from the rumor and includes them in the conversation key (deduplicated and sorted), ensuring all participants in a group DM are properly tracked together. Example: A message with sender 726... and p-tags [a94..., 7fa...] now creates conversation key: "726...:7fa...:a94..." (sorted alphabetically) --- src/services/gift-wrap.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/services/gift-wrap.ts b/src/services/gift-wrap.ts index b20d455..543b761 100644 --- a/src/services/gift-wrap.ts +++ b/src/services/gift-wrap.ts @@ -845,8 +845,15 @@ class GiftWrapManager { // Use a combination of gift wrap ID + seal ID const rumorId = `${giftWrap.id}:${seal.id}`; - // Create conversation key (sorted pubkeys for consistency) - const conversationKey = [seal.pubkey, recipientPubkey].sort().join(":"); + // Create conversation key including ALL participants from p-tags (for group DMs) + // Extract all recipient pubkeys from p-tags + const recipientPubkeys = rumor.tags + .filter((t: string[]) => t[0] === "p" && t[1]) + .map((t: string[]) => t[1]); + + // Include sender + all recipients, deduplicate and sort for consistency + const allParticipants = [seal.pubkey, ...recipientPubkeys]; + const conversationKey = [...new Set(allParticipants)].sort().join(":"); // Create the unsealed DM record const unsealed: UnsealedDM = {