mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19: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 eventNewer = !lastVerified || event.created_at > lastVerified;
|
||||
|
||||
if (nip05 !== authorStats?.nip05 && eventNewer) {
|
||||
if (nip05) {
|
||||
const tld = tldts.parse(nip05);
|
||||
if (tld.isIcann && !tld.isIp && !tld.isPrivate) {
|
||||
const pointer = await nip05Cache.fetch(nip05.toLowerCase(), { signal });
|
||||
if (pointer.pubkey === event.pubkey) {
|
||||
updates.nip05 = nip05;
|
||||
updates.nip05_domain = tld.domain;
|
||||
updates.nip05_hostname = tld.hostname;
|
||||
updates.nip05_last_verified_at = event.created_at;
|
||||
try {
|
||||
if (nip05 !== authorStats?.nip05 && eventNewer) {
|
||||
if (nip05) {
|
||||
const tld = tldts.parse(nip05);
|
||||
if (tld.isIcann && !tld.isIp && !tld.isPrivate) {
|
||||
const pointer = await nip05Cache.fetch(nip05.toLowerCase(), { signal });
|
||||
if (pointer.pubkey === event.pubkey) {
|
||||
updates.nip05 = nip05;
|
||||
updates.nip05_domain = tld.domain;
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ async function insertFavicon(kysely: Kysely<DittoTables>, domain: string, favico
|
|||
await kysely
|
||||
.insertInto('domain_favicons')
|
||||
.values({ domain, favicon, last_updated_at: nostrNow() })
|
||||
.onConflict((oc) => oc.column('domain').doUpdateSet({ favicon, last_updated_at: nostrNow() }))
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue