diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 16 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index ffbf1ba19..d9d385460 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -39,6 +39,7 @@ import { | |||
39 | import { VideoCaptionModel } from '../../models/video/video-caption' | 39 | import { VideoCaptionModel } from '../../models/video/video-caption' |
40 | import { videoRedundancyGetValidator } from '../../middlewares/validators/redundancy' | 40 | import { videoRedundancyGetValidator } from '../../middlewares/validators/redundancy' |
41 | import { getServerActor } from '../../helpers/utils' | 41 | import { getServerActor } from '../../helpers/utils' |
42 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | ||
42 | 43 | ||
43 | const activityPubClientRouter = express.Router() | 44 | const activityPubClientRouter = express.Router() |
44 | 45 | ||
@@ -164,6 +165,8 @@ function getAccountVideoRate (rateType: VideoRateType) { | |||
164 | async function videoController (req: express.Request, res: express.Response, next: express.NextFunction) { | 165 | async function videoController (req: express.Request, res: express.Response, next: express.NextFunction) { |
165 | const video: VideoModel = res.locals.video | 166 | const video: VideoModel = res.locals.video |
166 | 167 | ||
168 | if (video.isOwned() === false) return res.redirect(video.url) | ||
169 | |||
167 | // We need captions to render AP object | 170 | // We need captions to render AP object |
168 | video.VideoCaptions = await VideoCaptionModel.listVideoCaptions(video.id) | 171 | video.VideoCaptions = await VideoCaptionModel.listVideoCaptions(video.id) |
169 | 172 | ||
@@ -180,6 +183,9 @@ async function videoController (req: express.Request, res: express.Response, nex | |||
180 | 183 | ||
181 | async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { | 184 | async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { |
182 | const share = res.locals.videoShare as VideoShareModel | 185 | const share = res.locals.videoShare as VideoShareModel |
186 | |||
187 | if (share.Actor.isOwned() === false) return res.redirect(share.url) | ||
188 | |||
183 | const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.video, undefined) | 189 | const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.video, undefined) |
184 | 190 | ||
185 | return activityPubResponse(activityPubContextify(activity), res) | 191 | return activityPubResponse(activityPubContextify(activity), res) |
@@ -252,6 +258,8 @@ async function videoChannelFollowingController (req: express.Request, res: expre | |||
252 | async function videoCommentController (req: express.Request, res: express.Response, next: express.NextFunction) { | 258 | async function videoCommentController (req: express.Request, res: express.Response, next: express.NextFunction) { |
253 | const videoComment: VideoCommentModel = res.locals.videoComment | 259 | const videoComment: VideoCommentModel = res.locals.videoComment |
254 | 260 | ||
261 | if (videoComment.isOwned() === false) return res.redirect(videoComment.url) | ||
262 | |||
255 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined) | 263 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined) |
256 | const isPublic = true // Comments are always public | 264 | const isPublic = true // Comments are always public |
257 | const audience = getAudience(videoComment.Account.Actor, isPublic) | 265 | const audience = getAudience(videoComment.Account.Actor, isPublic) |
@@ -267,7 +275,9 @@ async function videoCommentController (req: express.Request, res: express.Respon | |||
267 | } | 275 | } |
268 | 276 | ||
269 | async function videoRedundancyController (req: express.Request, res: express.Response) { | 277 | async function videoRedundancyController (req: express.Request, res: express.Response) { |
270 | const videoRedundancy = res.locals.videoRedundancy | 278 | const videoRedundancy: VideoRedundancyModel = res.locals.videoRedundancy |
279 | if (videoRedundancy.isOwned() === false) return res.redirect(videoRedundancy.url) | ||
280 | |||
271 | const serverActor = await getServerActor() | 281 | const serverActor = await getServerActor() |
272 | 282 | ||
273 | const audience = getAudience(serverActor) | 283 | const audience = getAudience(serverActor) |
@@ -288,7 +298,7 @@ async function actorFollowing (req: express.Request, actor: ActorModel) { | |||
288 | return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count) | 298 | return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count) |
289 | } | 299 | } |
290 | 300 | ||
291 | return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, handler, req.query.page) | 301 | return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page) |
292 | } | 302 | } |
293 | 303 | ||
294 | async function actorFollowers (req: express.Request, actor: ActorModel) { | 304 | async function actorFollowers (req: express.Request, actor: ActorModel) { |
@@ -296,7 +306,7 @@ async function actorFollowers (req: express.Request, actor: ActorModel) { | |||
296 | return ActorFollowModel.listAcceptedFollowerUrlsForApi([ actor.id ], undefined, start, count) | 306 | return ActorFollowModel.listAcceptedFollowerUrlsForApi([ actor.id ], undefined, start, count) |
297 | } | 307 | } |
298 | 308 | ||
299 | return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, handler, req.query.page) | 309 | return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page) |
300 | } | 310 | } |
301 | 311 | ||
302 | function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) { | 312 | function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) { |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index e654bdd09..89fd0432f 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -31,6 +31,7 @@ import { | |||
31 | asyncMiddleware, | 31 | asyncMiddleware, |
32 | asyncRetryTransactionMiddleware, | 32 | asyncRetryTransactionMiddleware, |
33 | authenticate, | 33 | authenticate, |
34 | checkVideoFollowConstraints, | ||
34 | commonVideosFiltersValidator, | 35 | commonVideosFiltersValidator, |
35 | optionalAuthenticate, | 36 | optionalAuthenticate, |
36 | paginationValidator, | 37 | paginationValidator, |
@@ -123,6 +124,7 @@ videosRouter.get('/:id/description', | |||
123 | videosRouter.get('/:id', | 124 | videosRouter.get('/:id', |
124 | optionalAuthenticate, | 125 | optionalAuthenticate, |
125 | asyncMiddleware(videosGetValidator), | 126 | asyncMiddleware(videosGetValidator), |
127 | asyncMiddleware(checkVideoFollowConstraints), | ||
126 | getVideo | 128 | getVideo |
127 | ) | 129 | ) |
128 | videosRouter.post('/:id/views', | 130 | videosRouter.post('/:id/views', |