Remove NWC, return a Ln-Invoice header on the zap endpoint

This commit is contained in:
Alex Gleason
2024-05-28 16:54:57 -05:00
parent a690fa3096
commit 78044cc8b6
3 changed files with 41 additions and 59 deletions

View File

@@ -15,7 +15,7 @@ import { renderReblog, renderStatus } from '@/views/mastodon/statuses.ts';
import { Storages } from '@/storages.ts';
import { hydrateEvents } from '@/storages/hydrate.ts';
import { createEvent, paginationSchema, parseBody, updateListEvent } from '@/utils/api.ts';
import { getLnurl } from '@/utils/lnurl.ts';
import { getInvoice, getLnurl } from '@/utils/lnurl.ts';
import { lookupPubkey } from '@/utils/lookup.ts';
import { addTag, deleteTag } from '@/utils/tags.ts';
import { asyncReplaceAll } from '@/utils/text.ts';
@@ -450,15 +450,16 @@ const zapController: AppController = async (c) => {
const author = target?.author;
const meta = n.json().pipe(n.metadata()).catch({}).parse(author?.content);
const lnurl = getLnurl(meta);
const amount = params.data.amount;
if (target && lnurl) {
await createEvent({
const nostr = await createEvent({
kind: 9734,
content: params.data.comment ?? '',
tags: [
['e', target.id],
['p', target.pubkey],
['amount', params.data.amount.toString()],
['amount', amount.toString()],
['relays', Conf.relay],
['lnurl', lnurl],
],
@@ -467,7 +468,11 @@ const zapController: AppController = async (c) => {
const status = await renderStatus(target, { viewerPubkey: await c.get('signer')?.getPublicKey() });
status.zapped = true;
return c.json(status);
return c.json(status, {
headers: {
'Ln-Invoice': await getInvoice({ amount, nostr, lnurl }, signal),
},
});
} else {
return c.json({ error: 'Event not found.' }, 404);
}