From f0c66c1e92c4c679bd6bdbd383dd1146f8b7b04f Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Tue, 30 Apr 2024 21:23:25 -0300 Subject: [PATCH] fix(streaming): don't show posts from blocked users --- src/controllers/api/streaming.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index 668218d..c190c3e 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -8,8 +8,9 @@ import { getFeedPubkeys } from '@/queries.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'; import { Storages } from '@/storages.ts'; +import { UserStore } from '@/storages/UserStore.ts'; +import { getAdminStore } from '@/storages/adminStore.ts'; const debug = Debug('ditto:streaming'); @@ -71,9 +72,14 @@ const streamingController: AppController = (c) => { try { for await (const msg of Storages.pubsub.req([filter], { signal: controller.signal })) { if (msg[0] === 'EVENT') { - const [event] = await hydrateEvents({ - events: [msg[2]], - storage: eventsDB, + const store = new UserStore(pubkey as string, getAdminStore()); + + const [event] = await store.query([{ ids: [msg[2].id] }]); + if (!event) continue; + + await hydrateEvents({ + events: [event], + storage: store, signal: AbortSignal.timeout(1000), });