pipeline: remove awkward registerUser flow

This commit is contained in:
Alex Gleason 2024-03-16 15:07:45 -05:00
parent 04cdbd11c9
commit 648c32986b
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 0 additions and 51 deletions

View File

@ -35,7 +35,6 @@ async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise<void
trackHashtags(event),
fetchRelatedEvents(event, signal),
processMedia(event),
registerUser(event),
payZap(event, signal),
streamOut(event),
broadcast(event, signal),
@ -153,56 +152,6 @@ function processMedia({ tags, pubkey, user }: DittoEvent) {
}
}
/** Register the user, if applicable. */
async function registerUser(event: DittoEvent): Promise<void> {
if (event.kind !== 5951) return;
const signer = new AdminSigner();
const exists = (await eventsDB.count(
[{ kinds: [30361], authors: [Conf.pubkey], '#d': [event.pubkey], limit: 1 }],
)).count > 0;
if (exists) {
const feedback = await signer.signEvent({
kind: 7000,
content: '',
tags: [
['status', 'error', 'User already exists'],
['e', event.id],
['p', event.pubkey],
],
created_at: nostrNow(),
});
return handleEvent(feedback, AbortSignal.timeout(1000));
}
const user = await signer.signEvent({
kind: 30361,
tags: [
['d', event.pubkey],
],
content: '',
created_at: nostrNow(),
});
const resp = await signer.signEvent({
kind: 6951,
content: Conf.relay,
tags: [
['request', JSON.stringify(event)],
['i', Conf.relay, 'text'],
['p', event.pubkey],
['e', event.id],
],
created_at: nostrNow(),
});
await Promise.all([
handleEvent(user, AbortSignal.timeout(1000)),
handleEvent(resp, AbortSignal.timeout(1000)),
]);
}
/** Emit Nostr Wallet Connect event from zaps so users may pay. */
async function payZap(event: DittoEvent, signal: AbortSignal) {
if (event.kind !== 9734 || !event.user) return;