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)
This commit is contained in:
Claude
2026-01-20 12:46:07 +00:00
parent 6399d95f99
commit 530895b3d5

View File

@@ -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 = {