diff options
Diffstat (limited to 'server/lib/search.ts')
-rw-r--r-- | server/lib/search.ts | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/server/lib/search.ts b/server/lib/search.ts deleted file mode 100644 index b3363fbec..000000000 --- a/server/lib/search.ts +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | import express from 'express' | ||
2 | import { CONFIG } from '@server/initializers/config' | ||
3 | import { AccountBlocklistModel } from '@server/models/account/account-blocklist' | ||
4 | import { getServerActor } from '@server/models/application/application' | ||
5 | import { ServerBlocklistModel } from '@server/models/server/server-blocklist' | ||
6 | import { SearchTargetQuery } from '@shared/models' | ||
7 | |||
8 | function isSearchIndexSearch (query: SearchTargetQuery) { | ||
9 | if (query.searchTarget === 'search-index') return true | ||
10 | |||
11 | const searchIndexConfig = CONFIG.SEARCH.SEARCH_INDEX | ||
12 | |||
13 | if (searchIndexConfig.ENABLED !== true) return false | ||
14 | |||
15 | if (searchIndexConfig.IS_DEFAULT_SEARCH && !query.searchTarget) return true | ||
16 | |||
17 | return false | ||
18 | } | ||
19 | |||
20 | async function buildMutedForSearchIndex (res: express.Response) { | ||
21 | const serverActor = await getServerActor() | ||
22 | const accountIds = [ serverActor.Account.id ] | ||
23 | |||
24 | if (res.locals.oauth) { | ||
25 | accountIds.push(res.locals.oauth.token.User.Account.id) | ||
26 | } | ||
27 | |||
28 | const [ blockedHosts, blockedAccounts ] = await Promise.all([ | ||
29 | ServerBlocklistModel.listHostsBlockedBy(accountIds), | ||
30 | AccountBlocklistModel.listHandlesBlockedBy(accountIds) | ||
31 | ]) | ||
32 | |||
33 | return { | ||
34 | blockedHosts, | ||
35 | blockedAccounts | ||
36 | } | ||
37 | } | ||
38 | |||
39 | function isURISearch (search: string) { | ||
40 | if (!search) return false | ||
41 | |||
42 | return search.startsWith('http://') || search.startsWith('https://') | ||
43 | } | ||
44 | |||
45 | export { | ||
46 | isSearchIndexSearch, | ||
47 | buildMutedForSearchIndex, | ||
48 | isURISearch | ||
49 | } | ||