mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-30 18:44:20 +01:00
perf: hydrate repost events in reblog endpoint & streaming
This commit is contained in:
@@ -4,7 +4,7 @@ import { Conf } from '@/config.ts';
|
||||
import { nip19 } from '@/deps.ts';
|
||||
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||
import { getMediaLinks, parseNoteContent } from '@/note.ts';
|
||||
import { getAuthor, getEvent } from '@/queries.ts';
|
||||
import { getAuthor } from '@/queries.ts';
|
||||
import { jsonMediaDataSchema } from '@/schemas/nostr.ts';
|
||||
import { eventsDB } from '@/storages.ts';
|
||||
import { findReplyTag } from '@/tags.ts';
|
||||
@@ -100,21 +100,12 @@ async function renderStatus(event: DittoEvent, viewerPubkey?: string) {
|
||||
};
|
||||
}
|
||||
|
||||
type reblogOpts = {
|
||||
loadOriginalPostEvent?: boolean;
|
||||
};
|
||||
|
||||
async function renderReblog(event: DittoEvent, opts: reblogOpts) {
|
||||
const { loadOriginalPostEvent } = opts;
|
||||
|
||||
async function renderReblog(event: DittoEvent) {
|
||||
if (!event.author) return;
|
||||
|
||||
const repostId = event.tags.find(([name]) => name === 'e')?.[1];
|
||||
if (!repostId) return;
|
||||
|
||||
if (loadOriginalPostEvent) {
|
||||
event.repost = await getEvent(repostId, { kind: 1 });
|
||||
}
|
||||
if (!event.repost) return;
|
||||
|
||||
const reblog = await renderStatus(event.repost);
|
||||
|
||||
Reference in New Issue
Block a user