From 006a6ef16fda1a16716c927a731e74a6d7c57ee7 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 10 Aug 2023 10:32:57 -0700 Subject: [PATCH] Show possibly invalid zaps if we don't have the event in cache Changelog-Fixed: Fix zaps sometimes not appearing --- damus/Models/HomeModel.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift index 0e77fbb3..d6446bc1 100644 --- a/damus/Models/HomeModel.swift +++ b/damus/Models/HomeModel.swift @@ -1347,7 +1347,17 @@ func get_zap_target_pubkey(ev: NostrEvent, events: EventCache) -> Pubkey? { } // we can't trust the p tag on note zaps because they can be faked - return events.lookup(etag)?.pubkey + guard let pk = events.lookup(etag)?.pubkey else { + // We don't have the event in cache so we can't check the pubkey. + + // We could return this as an invalid zap but that wouldn't be correct + // all of the time, and may reject valid zaps. What we need is a new + // unvalidated zap state, but for now we simply leak a bit of correctness... + + return ev.referenced_pubkeys.just_one() + } + + return pk } func process_zap_event(damus_state: DamusState, ev: NostrEvent, completion: @escaping (ProcessZapResult) -> Void) {