pipeline: use fetchWorker properly for zaps, pass signal
This commit is contained in:
parent
24d1ff4aec
commit
40d3a46c16
|
@ -162,14 +162,14 @@ function processMedia({ tags, pubkey }: Event, { user }: EventData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Submit zap requests to Lightning nodes (for local users only). */
|
/** Submit zap requests to Lightning nodes (for local users only). */
|
||||||
async function submitZaps(event: Event, data: EventData) {
|
async function submitZaps(event: Event, data: EventData, signal = AbortSignal.timeout(5000)) {
|
||||||
if (event.kind === 9734 && data.user) {
|
if (event.kind === 9734 && data.user) {
|
||||||
const lnurl = event.tags.find(([name]) => name === 'lnurl')?.[1];
|
const lnurl = event.tags.find(([name]) => name === 'lnurl')?.[1];
|
||||||
const amount = event.tags.find(([name]) => name === 'amount')?.[1];
|
const amount = event.tags.find(([name]) => name === 'amount')?.[1];
|
||||||
if (lnurl && amount) {
|
if (lnurl && amount) {
|
||||||
try {
|
try {
|
||||||
const url = lnurlDecode(lnurl);
|
const url = lnurlDecode(lnurl);
|
||||||
const response = await fetchWorker(url);
|
const response = await fetchWorker(url, { signal });
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
const result = lnurlResponseSchema.parse(json);
|
const result = lnurlResponseSchema.parse(json);
|
||||||
if (result.tag === 'payRequest' && result.allowsNostr && result.nostrPubkey) {
|
if (result.tag === 'payRequest' && result.allowsNostr && result.nostrPubkey) {
|
||||||
|
@ -179,7 +179,7 @@ async function submitZaps(event: Event, data: EventData) {
|
||||||
params.set('nostr', JSON.stringify(event));
|
params.set('nostr', JSON.stringify(event));
|
||||||
params.set('lnurl', lnurl);
|
params.set('lnurl', lnurl);
|
||||||
callback.search = params.toString();
|
callback.search = params.toString();
|
||||||
await fetch(callback);
|
await fetchWorker(callback, { signal });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debug('lnurl error:', e);
|
debug('lnurl error:', e);
|
||||||
|
|
Loading…
Reference in New Issue