mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Wrap nip05 updates in a try-catch
This commit is contained in:
parent
8c60a4842b
commit
dd009de5be
2 changed files with 20 additions and 15 deletions
|
|
@ -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.
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue