Wrap nip05 updates in a try-catch

This commit is contained in:
Alex Gleason 2025-02-09 13:31:17 -06:00
parent 8c60a4842b
commit dd009de5be
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 20 additions and 15 deletions

View file

@ -213,24 +213,28 @@ async function updateAuthorData(event: NostrEvent, signal: AbortSignal): Promise
const lastVerified = authorStats?.nip05_last_verified_at; const lastVerified = authorStats?.nip05_last_verified_at;
const eventNewer = !lastVerified || event.created_at > lastVerified; const eventNewer = !lastVerified || event.created_at > lastVerified;
if (nip05 !== authorStats?.nip05 && eventNewer) { try {
if (nip05) { if (nip05 !== authorStats?.nip05 && eventNewer) {
const tld = tldts.parse(nip05); if (nip05) {
if (tld.isIcann && !tld.isIp && !tld.isPrivate) { const tld = tldts.parse(nip05);
const pointer = await nip05Cache.fetch(nip05.toLowerCase(), { signal }); if (tld.isIcann && !tld.isIp && !tld.isPrivate) {
if (pointer.pubkey === event.pubkey) { const pointer = await nip05Cache.fetch(nip05.toLowerCase(), { signal });
updates.nip05 = nip05; if (pointer.pubkey === event.pubkey) {
updates.nip05_domain = tld.domain; updates.nip05 = nip05;
updates.nip05_hostname = tld.hostname; updates.nip05_domain = tld.domain;
updates.nip05_last_verified_at = event.created_at; updates.nip05_hostname = tld.hostname;
updates.nip05_last_verified_at = event.created_at;
}
} }
} else {
updates.nip05 = null;
updates.nip05_domain = null;
updates.nip05_hostname = null;
updates.nip05_last_verified_at = event.created_at;
} }
} else {
updates.nip05 = null;
updates.nip05_domain = null;
updates.nip05_hostname = null;
updates.nip05_last_verified_at = event.created_at;
} }
} catch {
// Fallthrough.
} }
// Fetch favicon. // Fetch favicon.

View file

@ -45,6 +45,7 @@ async function insertFavicon(kysely: Kysely<DittoTables>, domain: string, favico
await kysely await kysely
.insertInto('domain_favicons') .insertInto('domain_favicons')
.values({ domain, favicon, last_updated_at: nostrNow() }) .values({ domain, favicon, last_updated_at: nostrNow() })
.onConflict((oc) => oc.column('domain').doUpdateSet({ favicon, last_updated_at: nostrNow() }))
.execute(); .execute();
} }