perf: hydrate repost events in reblog endpoint & streaming

This commit is contained in:
P. Reis
2024-04-13 18:16:15 -03:00
parent 24efca5ea0
commit 37bee709cd
5 changed files with 38 additions and 18 deletions

View File

@@ -6,6 +6,8 @@ import { getFeedPubkeys } from '@/queries.ts';
import { Sub } from '@/subs.ts';
import { bech32ToPubkey } from '@/utils.ts';
import { renderReblog, renderStatus } from '@/views/mastodon/statuses.ts';
import { hydrateEvents } from '@/storages/hydrate.ts';
import { eventsDB } from '@/storages.ts';
const debug = Debug('ditto:streaming');
@@ -64,7 +66,14 @@ const streamingController: AppController = (c) => {
if (filter) {
for await (const event of Sub.sub(socket, '1', [filter])) {
if (event.kind === 6) {
const status = await renderReblog(event, { loadOriginalPostEvent: true });
await hydrateEvents({
events: [event],
relations: ['repost', 'author'],
storage: eventsDB,
signal: AbortSignal.timeout(1000),
});
const status = await renderReblog(event);
if (status) {
send('update', status);
}