aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/search.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/search.ts')
-rw-r--r--server/controllers/api/search.ts11
1 files changed, 2 insertions, 9 deletions
diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts
index 959d79855..bb7174891 100644
--- a/server/controllers/api/search.ts
+++ b/server/controllers/api/search.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { buildNSFWFilter } from '../../helpers/express-utils' 2import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
3import { getFormattedObjects, getServerActor } from '../../helpers/utils' 3import { getFormattedObjects, getServerActor } from '../../helpers/utils'
4import { VideoModel } from '../../models/video/video' 4import { VideoModel } from '../../models/video/video'
5import { 5import {
@@ -88,7 +88,7 @@ async function searchVideoChannelURI (search: string, isWebfingerSearch: boolean
88 88
89 if (isUserAbleToSearchRemoteURI(res)) { 89 if (isUserAbleToSearchRemoteURI(res)) {
90 try { 90 try {
91 const actor = await getOrCreateActorAndServerAndModel(uri) 91 const actor = await getOrCreateActorAndServerAndModel(uri, true, true)
92 videoChannel = actor.VideoChannel 92 videoChannel = actor.VideoChannel
93 } catch (err) { 93 } catch (err) {
94 logger.info('Cannot search remote video channel %s.', uri, { err }) 94 logger.info('Cannot search remote video channel %s.', uri, { err })
@@ -152,10 +152,3 @@ async function searchVideoURI (url: string, res: express.Response) {
152 data: video ? [ video.toFormattedJSON() ] : [] 152 data: video ? [ video.toFormattedJSON() ] : []
153 }) 153 })
154} 154}
155
156function isUserAbleToSearchRemoteURI (res: express.Response) {
157 const user: User = res.locals.oauth ? res.locals.oauth.token.User : undefined
158
159 return CONFIG.SEARCH.REMOTE_URI.ANONYMOUS === true ||
160 (CONFIG.SEARCH.REMOTE_URI.USERS === true && user !== undefined)
161}