mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-24 07:44:28 +01:00
perf: hydrate repost events in reblog endpoint & streaming
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user