import * as express from 'express'
-import { buildNSFWFilter } from '../../helpers/express-utils'
+import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
import { getFormattedObjects, getServerActor } from '../../helpers/utils'
import { VideoModel } from '../../models/video/video'
import {
if (isUserAbleToSearchRemoteURI(res)) {
try {
- const actor = await getOrCreateActorAndServerAndModel(uri)
+ const actor = await getOrCreateActorAndServerAndModel(uri, true, true)
videoChannel = actor.VideoChannel
} catch (err) {
logger.info('Cannot search remote video channel %s.', uri, { err })
data: video ? [ video.toFormattedJSON() ] : []
})
}
-
-function isUserAbleToSearchRemoteURI (res: express.Response) {
- const user: User = res.locals.oauth ? res.locals.oauth.token.User : undefined
-
- return CONFIG.SEARCH.REMOTE_URI.ANONYMOUS === true ||
- (CONFIG.SEARCH.REMOTE_URI.USERS === true && user !== undefined)
-}