mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-16 20:04:24 +01:00
refactor(scavenger): put SQL insert into try-catch block
This commit is contained in:
@@ -36,13 +36,17 @@ async function handleEvent9735(kysely: Kysely<DittoTables>, event: NostrEvent) {
|
||||
const zappedEventId = zapRequest.tags.find(([name]) => name === 'e')?.[1];
|
||||
if (!zappedEventId) return;
|
||||
|
||||
await kysely.insertInto('event_zaps').values({
|
||||
receipt_id: event.id,
|
||||
target_event_id: zappedEventId,
|
||||
sender_pubkey: zapRequest.pubkey,
|
||||
amount_millisats,
|
||||
comment: zapRequest.content,
|
||||
}).execute();
|
||||
try {
|
||||
await kysely.insertInto('event_zaps').values({
|
||||
receipt_id: event.id,
|
||||
target_event_id: zappedEventId,
|
||||
sender_pubkey: zapRequest.pubkey,
|
||||
amount_millisats,
|
||||
comment: zapRequest.content,
|
||||
}).execute();
|
||||
} catch {
|
||||
// receipt_id is unique, do nothing
|
||||
}
|
||||
}
|
||||
|
||||
export { scavengerEvent };
|
||||
|
||||
Reference in New Issue
Block a user