refactor(scavenger): put SQL insert into try-catch block

This commit is contained in:
P. Reis 2024-06-21 21:45:55 -03:00
parent 1b30f10a9f
commit 771d7f79db

View file

@ -36,6 +36,7 @@ async function handleEvent9735(kysely: Kysely<DittoTables>, event: NostrEvent) {
const zappedEventId = zapRequest.tags.find(([name]) => name === 'e')?.[1]; const zappedEventId = zapRequest.tags.find(([name]) => name === 'e')?.[1];
if (!zappedEventId) return; if (!zappedEventId) return;
try {
await kysely.insertInto('event_zaps').values({ await kysely.insertInto('event_zaps').values({
receipt_id: event.id, receipt_id: event.id,
target_event_id: zappedEventId, target_event_id: zappedEventId,
@ -43,6 +44,9 @@ async function handleEvent9735(kysely: Kysely<DittoTables>, event: NostrEvent) {
amount_millisats, amount_millisats,
comment: zapRequest.content, comment: zapRequest.content,
}).execute(); }).execute();
} catch {
// receipt_id is unique, do nothing
}
} }
export { scavengerEvent }; export { scavengerEvent };