diff --git a/src/controllers/api/accounts.ts b/src/controllers/api/accounts.ts index 58b93b4..473dd63 100644 --- a/src/controllers/api/accounts.ts +++ b/src/controllers/api/accounts.ts @@ -197,7 +197,7 @@ const updateCredentialsController: AppController = async (c) => { } const author = await getAuthor(pubkey); - const meta = author ? n.json().pipe(n.metadata()).parse(author.content) : {}; + const meta = author ? n.json().pipe(n.metadata()).catch({}).parse(author.content) : {}; const { avatar: avatarFile, diff --git a/src/controllers/api/instance.ts b/src/controllers/api/instance.ts index ac9810e..188d68f 100644 --- a/src/controllers/api/instance.ts +++ b/src/controllers/api/instance.ts @@ -10,7 +10,7 @@ const instanceController: AppController = async (c) => { const { signal } = c.req.raw; const [event] = await Storages.db.query([{ kinds: [0], authors: [Conf.pubkey], limit: 1 }], { signal }); - const meta = n.json().pipe(serverMetaSchema).parse(event?.content); + const meta = n.json().pipe(serverMetaSchema).catch({}).parse(event?.content); /** Protocol to use for WebSocket URLs, depending on the protocol of the `LOCAL_DOMAIN`. */ const wsProtocol = protocol === 'http:' ? 'ws:' : 'wss:'; diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index 8421900..56ea38b 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -405,7 +405,7 @@ const zapController: AppController = async (c) => { const target = await getEvent(id, { kind: 1, relations: ['author', 'event_stats', 'author_stats'], signal }); const author = target?.author; - const meta = n.json().pipe(n.metadata()).parse(author?.content); + const meta = n.json().pipe(n.metadata()).catch({}).parse(author?.content); const lnurl = getLnurl(meta); if (target && lnurl) { diff --git a/src/controllers/nostr/relay-info.ts b/src/controllers/nostr/relay-info.ts index f42c8df..a56df51 100644 --- a/src/controllers/nostr/relay-info.ts +++ b/src/controllers/nostr/relay-info.ts @@ -8,7 +8,7 @@ import { Storages } from '@/storages.ts'; const relayInfoController: AppController = async (c) => { const { signal } = c.req.raw; const [event] = await Storages.db.query([{ kinds: [0], authors: [Conf.pubkey], limit: 1 }], { signal }); - const meta = n.json().pipe(serverMetaSchema).parse(event?.content); + const meta = n.json().pipe(serverMetaSchema).catch({}).parse(event?.content); return c.json({ name: meta.name ?? 'Ditto', diff --git a/src/pipeline.ts b/src/pipeline.ts index 16876f2..b193617 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -111,7 +111,7 @@ async function parseMetadata(event: NostrEvent, signal: AbortSignal): Promise { - const content = n.json().pipe(n.metadata()).parse(event.content); + const content = n.json().pipe(n.metadata()).catch({}).parse(event.content); return { type: 'Person', diff --git a/src/views/mastodon/accounts.ts b/src/views/mastodon/accounts.ts index 50458bf..e00856e 100644 --- a/src/views/mastodon/accounts.ts +++ b/src/views/mastodon/accounts.ts @@ -28,7 +28,7 @@ async function renderAccount( about, lud06, lud16, - } = n.json().pipe(n.metadata()).parse(event.content); + } = n.json().pipe(n.metadata()).catch({}).parse(event.content); const npub = nip19.npubEncode(pubkey); const parsed05 = await parseAndVerifyNip05(nip05, pubkey);