diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-24 15:36:50 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 687d638c2bee0d223f206168173b1b95adbad983 (patch) | |
tree | 957741b0ba704562a233181510bb8fda0102c8a5 /server/controllers/api | |
parent | f5b0af50c85e2f8b6b2b054ac1f47123cacbe08d (diff) | |
download | PeerTube-687d638c2bee0d223f206168173b1b95adbad983.tar.gz PeerTube-687d638c2bee0d223f206168173b1b95adbad983.tar.zst PeerTube-687d638c2bee0d223f206168173b1b95adbad983.zip |
Fetch outbox when searching an actor
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/accounts.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/search.ts | 11 | ||||
-rw-r--r-- | server/controllers/api/video-channel.ts | 4 |
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 { | |||
11 | import { accountsNameWithHostGetValidator, accountsSortValidator, videosSortValidator } from '../../middlewares/validators' | 11 | import { accountsNameWithHostGetValidator, accountsSortValidator, videosSortValidator } from '../../middlewares/validators' |
12 | import { AccountModel } from '../../models/account/account' | 12 | import { AccountModel } from '../../models/account/account' |
13 | import { VideoModel } from '../../models/video/video' | 13 | import { VideoModel } from '../../models/video/video' |
14 | import { buildNSFWFilter } from '../../helpers/express-utils' | 14 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
15 | import { VideoChannelModel } from '../../models/video/video-channel' | 15 | import { VideoChannelModel } from '../../models/video/video-channel' |
16 | 16 | ||
17 | const accountsRouter = express.Router() | 17 | const accountsRouter = express.Router() |
@@ -73,8 +73,10 @@ async function listVideoAccountChannels (req: express.Request, res: express.Resp | |||
73 | 73 | ||
74 | async function listAccountVideos (req: express.Request, res: express.Response, next: express.NextFunction) { | 74 | async 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { buildNSFWFilter } from '../../helpers/express-utils' | 2 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
3 | import { getFormattedObjects, getServerActor } from '../../helpers/utils' | 3 | import { getFormattedObjects, getServerActor } from '../../helpers/utils' |
4 | import { VideoModel } from '../../models/video/video' | 4 | import { VideoModel } from '../../models/video/video' |
5 | import { | 5 | import { |
@@ -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 | |||
156 | function 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 | |||
19 | import { sendUpdateActor } from '../../lib/activitypub/send' | 19 | import { sendUpdateActor } from '../../lib/activitypub/send' |
20 | import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' | 20 | import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' |
21 | import { createVideoChannel } from '../../lib/video-channel' | 21 | import { createVideoChannel } from '../../lib/video-channel' |
22 | import { buildNSFWFilter, createReqFiles } from '../../helpers/express-utils' | 22 | import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
23 | import { setAsyncActorKeys } from '../../lib/activitypub' | 23 | import { setAsyncActorKeys } from '../../lib/activitypub' |
24 | import { AccountModel } from '../../models/account/account' | 24 | import { AccountModel } from '../../models/account/account' |
25 | import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers' | 25 | import { CONFIG, IMAGE_MIMETYPE_EXT, sequelizeTypescript } from '../../initializers' |
@@ -210,8 +210,10 @@ async function getVideoChannel (req: express.Request, res: express.Response, nex | |||
210 | 210 | ||
211 | async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { | 211 | async 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, |