@@ -54,6 +54,21 @@ function findByTag(tags: string[][], tag: string): string | undefined {
5454 }
5555}
5656
57+ function getZapKind ( event : NostrEvent ) : "public" | "private" | "anonymous" {
58+ const anonTag = event . tags . find ( ( t ) => {
59+ if ( t [ 0 ] === "anon" ) {
60+ return true ;
61+ }
62+ } ) ;
63+
64+ // If the anon field is empty it's anon, if it has other elements its private, otherwise it's public
65+ if ( anonTag ) {
66+ return anonTag . length < 2 ? "anonymous" : "private" ;
67+ }
68+
69+ return "public" ;
70+ }
71+
5772async function simpleZapFromEvent (
5873 event : NostrEvent ,
5974 wallet : MutinyWallet
@@ -66,8 +81,6 @@ async function simpleZapFromEvent(
6681 const from = request . pubkey ;
6782
6883 const content = request . content ;
69- const anon = findByTag ( request . tags , "anon" ) ;
70-
7184 const bolt11 = findByTag ( event . tags , "bolt11" ) || "" ;
7285
7386 if ( ! bolt11 ) {
@@ -100,13 +113,7 @@ async function simpleZapFromEvent(
100113 }
101114
102115 return {
103- // If the anon field is empty it's anon, if it has length it's private, otherwise it's public
104- kind :
105- typeof anon === "string"
106- ? anon . length
107- ? "private"
108- : "anonymous"
109- : "public" ,
116+ kind : getZapKind ( request ) ,
110117 from_hexpub : from ,
111118 to_hexpub : to ,
112119 timestamp : BigInt ( event . created_at ) ,
@@ -280,7 +287,7 @@ export const fetchZaps: ResourceFetcher<
280287 zaps . push ( event ) ;
281288 }
282289 } catch ( e ) {
283- console . error ( "Failed to parse zap event: " , object ) ;
290+ console . error ( "Failed to parse zap event: " , object , e ) ;
284291 }
285292 }
286293 }
0 commit comments