Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match NWC events by p tag instead event pk #1187

Merged
merged 1 commit into from
May 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions mutiny-core/src/nostr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,9 +1547,25 @@ impl<S: MutinyStorage, P: PrimalApi, C: NostrClient> NostrManager<S, P, C> {
) -> anyhow::Result<Option<Event>> {
let nwc = {
let vec = self.nwc.read().unwrap();
vec.iter()
.find(|nwc| nwc.client_pubkey() == event.pubkey)
.cloned()
// Need to find the p tag, not the client pubkey because there can be duplicates
// of the same client pubkey but we guarantee that the p tag is unique.
let p_tag = event
.tags
.iter()
.find_map(|tag| {
if let Tag::PublicKey {
public_key,
uppercase: false,
..
} = tag
{
Some(*public_key)
} else {
None
}
})
.ok_or(anyhow::anyhow!("No P tag found"))?;
vec.iter().find(|nwc| nwc.server_pubkey() == p_tag).cloned()
};

self.storage.set_nwc_sync_time(event.created_at.as_u64())?;
Expand Down
Loading