bug: ignore zapperPubkey for forward zaps

This commit is contained in:
Kieran 2023-04-05 12:36:12 +01:00
parent 5944cfd918
commit 8be0c7dd3d
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
3 changed files with 7 additions and 5 deletions

View File

@ -114,9 +114,10 @@ export default function Note(props: NoteProps) {
);
const zaps = useMemo(() => {
const sortedZaps = getReactions(related, ev.id, EventKind.ZapReceipt)
.map(parseZap)
.filter(z => z.valid && z.sender !== ev.pubkey);
.map(a => parseZap(a, ev))
.filter(z => z.valid);
sortedZaps.sort((a, b) => b.amount - a.amount);
console.debug(sortedZaps);
return sortedZaps;
}, [related]);
const totalReactions = positive.length + negative.length + reposts.length + zaps.length;

View File

@ -22,7 +22,7 @@ function getInvoice(zap: TaggedRawEvent): InvoiceDetails | undefined {
return decodeInvoice(bolt11);
}
export function parseZap(zapReceipt: TaggedRawEvent): ParsedZap {
export function parseZap(zapReceipt: TaggedRawEvent, refNote?: TaggedRawEvent): ParsedZap {
let innerZapJson = findTag(zapReceipt, "description");
if (innerZapJson) {
try {
@ -35,6 +35,7 @@ export function parseZap(zapReceipt: TaggedRawEvent): ParsedZap {
// old format, ignored
throw new Error("deprecated zap format");
}
const isForwardedZap = refNote?.tags.some(a => a[0] === "zap") ?? false;
const anonZap = findTag(zapRequest, "anon");
const metaHash = sha256(innerZapJson);
const ret: ParsedZap = {
@ -65,7 +66,7 @@ export function parseZap(zapReceipt: TaggedRawEvent): ParsedZap {
ret.valid = false;
ret.errors.push("amount tag does not match invoice amount");
}
if (UserCache.getFromCache(ret.receiver)?.zapService !== ret.zapService) {
if (UserCache.getFromCache(ret.receiver)?.zapService !== ret.zapService && !isForwardedZap) {
ret.valid = false;
ret.errors.push("zap service pubkey doesn't match");
}

View File

@ -18,7 +18,7 @@ export default function useZapsFeed(pubkey?: HexKey) {
const zaps = useMemo(() => {
if (zapsFeed.data) {
const profileZaps = zapsFeed.data
.map(parseZap)
.map(a => parseZap(a))
.filter(z => z.valid && z.receiver === pubkey && z.sender !== pubkey && !z.event);
profileZaps.sort((a, b) => b.amount - a.amount);
return profileZaps;