Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit f79c4eb

Browse files
committed
Match NWC events by p tag instead event pk
1 parent 43599f4 commit f79c4eb

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

mutiny-core/src/nostr/mod.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,9 +1547,25 @@ impl<S: MutinyStorage, P: PrimalApi, C: NostrClient> NostrManager<S, P, C> {
15471547
) -> anyhow::Result<Option<Event>> {
15481548
let nwc = {
15491549
let vec = self.nwc.read().unwrap();
1550-
vec.iter()
1551-
.find(|nwc| nwc.client_pubkey() == event.pubkey)
1552-
.cloned()
1550+
// Need to find the p tag, not the client pubkey because there can be duplicates
1551+
// of the same client pubkey but we guarantee that the p tag is unique.
1552+
let p_tag = event
1553+
.tags
1554+
.iter()
1555+
.find_map(|tag| {
1556+
if let Tag::PublicKey {
1557+
public_key,
1558+
uppercase: false,
1559+
..
1560+
} = tag
1561+
{
1562+
Some(*public_key)
1563+
} else {
1564+
None
1565+
}
1566+
})
1567+
.ok_or(anyhow::anyhow!("No P tag found"))?;
1568+
vec.iter().find(|nwc| nwc.server_pubkey() == p_tag).cloned()
15531569
};
15541570

15551571
self.storage.set_nwc_sync_time(event.created_at.as_u64())?;

0 commit comments

Comments
 (0)