From b2bc46ac5769c4d6222bb8863d68967fe9ab2e9d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 20 Mar 2024 12:01:38 -0500 Subject: [PATCH] Removed DittoFilter usages I missed earlier --- src/controllers/api/search.ts | 2 +- src/controllers/api/streaming.ts | 9 ++++++--- src/controllers/api/timelines.ts | 13 +++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/controllers/api/search.ts b/src/controllers/api/search.ts index f335d855..ec85192b 100644 --- a/src/controllers/api/search.ts +++ b/src/controllers/api/search.ts @@ -1,6 +1,6 @@ +import { NostrFilter } from '@soapbox/nspec'; import { AppController } from '@/app.ts'; import { nip19, type NostrEvent, z } from '@/deps.ts'; -import { type NostrFilter } from '@/interfaces/DittoFilter.ts'; import { booleanParamSchema } from '@/schema.ts'; import { nostrIdSchema } from '@/schemas/nostr.ts'; import { searchStore } from '@/storages.ts'; diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index c11484eb..e3486bc9 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -1,6 +1,7 @@ +import { NostrFilter } from '@soapbox/nspec'; import { type AppController } from '@/app.ts'; +import { Conf } from '@/config.ts'; import { Debug, z } from '@/deps.ts'; -import { NostrFilter } from '@/interfaces/DittoFilter.ts'; import { getAuthor, getFeedPubkeys } from '@/queries.ts'; import { Sub } from '@/subs.ts'; import { bech32ToPubkey } from '@/utils.ts'; @@ -83,16 +84,18 @@ async function topicToFilter( query: Record, pubkey: string | undefined, ): Promise { + const { host } = Conf.url; + switch (topic) { case 'public': return { kinds: [1] }; case 'public:local': - return { kinds: [1], local: true }; + return { kinds: [1], search: `domain:${host}` }; case 'hashtag': if (query.tag) return { kinds: [1], '#t': [query.tag] }; break; case 'hashtag:local': - if (query.tag) return { kinds: [1], '#t': [query.tag], local: true }; + if (query.tag) return { kinds: [1], '#t': [query.tag], search: `domain:${host}` }; break; case 'user': // HACK: this puts the user's entire contacts list into RAM, diff --git a/src/controllers/api/timelines.ts b/src/controllers/api/timelines.ts index c1c669ee..ebea935c 100644 --- a/src/controllers/api/timelines.ts +++ b/src/controllers/api/timelines.ts @@ -1,6 +1,7 @@ +import { NostrFilter } from '@soapbox/nspec'; import { type AppContext, type AppController } from '@/app.ts'; +import { Conf } from '@/config.ts'; import { z } from '@/deps.ts'; -import { type NostrFilter } from '@/interfaces/DittoFilter.ts'; import { getFeedPubkeys } from '@/queries.ts'; import { booleanParamSchema } from '@/schema.ts'; import { eventsDB } from '@/storages.ts'; @@ -22,7 +23,15 @@ const publicQuerySchema = z.object({ const publicTimelineController: AppController = (c) => { const params = paginationSchema.parse(c.req.query()); const { local } = publicQuerySchema.parse(c.req.query()); - return renderStatuses(c, [{ kinds: [1], local, ...params }]); + const { host } = Conf.url; + + const filter: NostrFilter = { kinds: [1], ...params }; + + if (local) { + filter.search = `domain:${host}`; + } + + return renderStatuses(c, [filter]); }; const hashtagTimelineController: AppController = (c) => {