Only parse mentions with valid pubkeys

Fixes https://gitlab.com/soapbox-pub/ditto/-/issues/290
This commit is contained in:
Alex Gleason 2025-02-03 14:53:38 -06:00
parent 00953e4a0a
commit cfa6848927
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -7,7 +7,7 @@ import { MastodonMention } from '@/entities/MastodonMention.ts';
import { MastodonStatus } from '@/entities/MastodonStatus.ts'; import { MastodonStatus } from '@/entities/MastodonStatus.ts';
import { type DittoEvent } from '@/interfaces/DittoEvent.ts'; import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
import { Storages } from '@/storages.ts'; import { Storages } from '@/storages.ts';
import { nostrDate } from '@/utils.ts'; import { isNostrId, nostrDate } from '@/utils.ts';
import { getMediaLinks, parseNoteContent, stripimeta } from '@/utils/note.ts'; import { getMediaLinks, parseNoteContent, stripimeta } from '@/utils/note.ts';
import { findReplyTag } from '@/utils/tags.ts'; import { findReplyTag } from '@/utils/tags.ts';
import { unfurlCardCached } from '@/utils/unfurl.ts'; import { unfurlCardCached } from '@/utils/unfurl.ts';
@ -41,8 +41,8 @@ async function renderStatus(event: DittoEvent, opts: RenderStatusOpts): Promise<
const mentionedPubkeys = [ const mentionedPubkeys = [
...new Set( ...new Set(
event.tags event.tags
.filter((tag) => tag[0] === 'p') .filter(([name, value]) => name === 'p' && isNostrId(value))
.map((tag) => tag[1]), .map(([, value]) => value),
), ),
]; ];