fix: zapper for zap goals

This commit is contained in:
Kieran 2023-11-03 10:07:06 +09:00
parent 0cef163eb9
commit 9eb029e1dc
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 43 additions and 29 deletions

View File

@ -45,6 +45,7 @@ export class Zapper {
* Create targets from Event * Create targets from Event
*/ */
static fromEvent(ev: NostrEvent) { static fromEvent(ev: NostrEvent) {
if (ev.tags.some(a => a[0] === "zap")) {
return ev.tags return ev.tags
.filter(a => a[0] === "zap") .filter(a => a[0] === "zap")
.map(v => { .map(v => {
@ -72,6 +73,19 @@ export class Zapper {
} as ZapTarget; } as ZapTarget;
} }
}); });
} else {
return [
{
type: "pubkey",
value: ev.pubkey,
weight: 1,
zap: {
pubkey: ev.pubkey,
event: NostrLink.fromEvent(ev),
},
} as ZapTarget,
];
}
} }
async send(wallet: LNWallet | undefined, targets: Array<ZapTarget>, amount: number) { async send(wallet: LNWallet | undefined, targets: Array<ZapTarget>, amount: number) {

View File

@ -63,10 +63,10 @@ export function parseZap(zapReceipt: NostrEvent, userCache: FeedCache<MetadataCa
ret.valid = false; ret.valid = false;
ret.errors.push("amount tag does not match invoice amount"); ret.errors.push("amount tag does not match invoice amount");
} }
if (userCache.getFromCache(ret.receiver)?.zapService !== ret.zapService && !isForwardedZap) { /*if (userCache.getFromCache(ret.receiver)?.zapService !== ret.zapService && !isForwardedZap) {
ret.valid = false; ret.valid = false;
ret.errors.push("zap service pubkey doesn't match"); ret.errors.push("zap service pubkey doesn't match");
} }*/
if (!ret.valid) { if (!ret.valid) {
Log("Invalid zap %O", ret); Log("Invalid zap %O", ret);