From 25a4384587de898484eb0853f4a51ccde16913bf Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 20 Mar 2024 13:49:02 -0500 Subject: [PATCH] Hydrate event author in pipeline to relieve streaming API --- src/controllers/api/streaming.ts | 3 +-- src/pipeline.ts | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index e3486bc9..7aa3a20b 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -63,8 +63,7 @@ const streamingController: AppController = (c) => { if (filter) { for await (const event of Sub.sub(socket, '1', [filter])) { - const author = await getAuthor(event.pubkey); - const status = await renderStatus({ ...event, author }, pubkey); + const status = await renderStatus(event, pubkey); if (status) { send('update', status); } diff --git a/src/pipeline.ts b/src/pipeline.ts index 72b16eda..1f34b0f2 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -6,6 +6,7 @@ import { deleteAttachedMedia } from '@/db/unattached-media.ts'; import { Debug, LNURL, type NostrEvent } from '@/deps.ts'; import { DittoEvent } from '@/interfaces/DittoEvent.ts'; import { isEphemeralKind } from '@/kinds.ts'; +import { getAuthor } from '@/queries.ts'; import { updateStats } from '@/stats.ts'; import { purifyEvent } from '@/storages/hydrate.ts'; import { cache, client, eventsDB, reqmeister } from '@/storages.ts'; @@ -58,6 +59,9 @@ async function hydrateEvent(event: DittoEvent): Promise { const [user] = await eventsDB.query([{ kinds: [30361], authors: [Conf.pubkey], '#d': [event.pubkey], limit: 1 }]); event.user = user; + const author = await getAuthor(event.pubkey); + event.author = author; + const domain = await db .selectFrom('pubkey_domains') .select('domain')