aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-24 15:36:50 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit687d638c2bee0d223f206168173b1b95adbad983 (patch)
tree957741b0ba704562a233181510bb8fda0102c8a5 /server/controllers
parentf5b0af50c85e2f8b6b2b054ac1f47123cacbe08d (diff)
downloadPeerTube-687d638c2bee0d223f206168173b1b95adbad983.tar.gz
PeerTube-687d638c2bee0d223f206168173b1b95adbad983.tar.zst
PeerTube-687d638c2bee0d223f206168173b1b95adbad983.zip
Fetch outbox when searching an actor
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/accounts.ts4
-rw-r--r--server/controllers/api/search.ts11
-rw-r--r--server/controllers/api/video-channel.ts4
3 files changed, 8 insertions, 11 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index 7b7e5e740..b7691ccba 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -11,7 +11,7 @@ import {
11import { accountsNameWithHostGetValidator, accountsSortValidator, videosSortValidator } from '../../middlewares/validators' 11import { accountsNameWithHostGetValidator, accountsSortValidator, videosSortValidator } from '../../middlewares/validators'
12import { AccountModel } from '../../models/account/account' 12import { AccountModel } from '../../models/account/account'
13import { VideoModel } from '../../models/video/video' 13import { VideoModel } from '../../models/video/video'
14import { buildNSFWFilter } from '../../helpers/express-utils' 14import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
15import { VideoChannelModel } from '../../models/video/video-channel' 15import { VideoChannelModel } from '../../models/video/video-channel'
16 16
17const accountsRouter = express.Router() 17const accountsRouter = express.Router()
@@ -73,8 +73,10 @@ async function listVideoAccountChannels (req: express.Request, res: express.Resp
73 73
74async function listAccountVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 74async function listAccountVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
75 const account: AccountModel = res.locals.account 75 const account: AccountModel = res.locals.account
76 const actorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
76 77
77 const resultList = await VideoModel.listForApi({ 78 const resultList = await VideoModel.listForApi({
79 actorId,
78 start: req.query.start, 80 start: req.query.start,
79 count: req.query.count, 81 count: req.query.count,
80 sort: req.query.sort, 82 sort: req.query.sort,
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}
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index bd08d7a08..a7a36080b 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -19,7 +19,7 @@ import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../m
19import { sendUpdateActor } from '../../lib/activitypub/send' 19import { sendUpdateActor } from '../../lib/activitypub/send'
20import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' 20import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared'
21import { createVideoChannel } from '../../lib/video-channel' 21import { createVideoChannel } from '../../lib/video-channel'
22import { buildNSFWFilter, createReqFiles } from '../../helpers/express-utils' 22import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
23import { setAsyncActorKeys } from '../../lib/activitypub' 23import { setAsyncActorKeys } from '../../lib/activitypub'
24import { AccountModel } from '../../models/account/account' 24import { AccountModel } from '../../models/account/account'
25import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers' 25import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers'
@@ -210,8 +210,10 @@ async function getVideoChannel (req: express.Request, res: express.Response, nex
210 210
211async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 211async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
212 const videoChannelInstance: VideoChannelModel = res.locals.videoChannel 212 const videoChannelInstance: VideoChannelModel = res.locals.videoChannel
213 const actorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
213 214
214 const resultList = await VideoModel.listForApi({ 215 const resultList = await VideoModel.listForApi({
216 actorId,
215 start: req.query.start, 217 start: req.query.start,
216 count: req.query.count, 218 count: req.query.count,
217 sort: req.query.sort, 219 sort: req.query.sort,