fix: filter out invalid pubkeys

This commit is contained in:
P. Reis 2025-02-25 20:04:28 -03:00
parent 73beef72ac
commit 05a4a5a5c9

View file

@ -7,7 +7,7 @@ import { NSchema as n } from '@nostrify/nostrify';
import { z } from 'zod'; import { z } from 'zod';
import { type DittoEvent } from '@/interfaces/DittoEvent.ts'; import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
import { fallbackAuthor } from '@/utils.ts'; import { fallbackAuthor, isNostrId } from '@/utils.ts';
import { findQuoteTag } from '@/utils/tags.ts'; import { findQuoteTag } from '@/utils/tags.ts';
import { findQuoteInContent } from '@/utils/note.ts'; import { findQuoteInContent } from '@/utils/note.ts';
import { getAmount } from '@/utils/bolt11.ts'; import { getAmount } from '@/utils/bolt11.ts';
@ -132,7 +132,9 @@ export function assembleEvents(
event.quote = b.find((e) => matchFilter({ kinds: [1, 20], ids: [id] }, e)); event.quote = b.find((e) => matchFilter({ kinds: [1, 20], ids: [id] }, e));
} }
const pubkeys = event.tags.filter(([name]) => name === 'p').map(([_name, value]) => value); const pubkeys = event.tags.filter(([name]) => name === 'p')
.map(([_name, value]) => value)
.filter((pubkey) => isNostrId(pubkey));
event.mentions = b.filter((e) => matchFilter({ kinds: [0], authors: pubkeys }, e)); event.mentions = b.filter((e) => matchFilter({ kinds: [0], authors: pubkeys }, e));
} }