diff options
author | buoyantair <buoyantair@protonmail.com> | 2018-11-18 21:55:52 +0530 |
---|---|---|
committer | buoyantair <buoyantair@protonmail.com> | 2018-11-18 21:55:52 +0530 |
commit | b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13 (patch) | |
tree | dcdf451ac431ec7953bee58e814f642d1c370d1b /server/controllers/activitypub | |
parent | 92e07c3b5d9dbf2febedb1b5b87ec676eb6d1ac8 (diff) | |
parent | 9d0b856e930ee1c676d16a56408a3e4a18f8f978 (diff) | |
download | PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.tar.gz PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.tar.zst PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.zip |
Merge branch 'develop' of https://github.com/Chocobozzz/PeerTube into move-utils-to-shared
Diffstat (limited to 'server/controllers/activitypub')
-rw-r--r-- | server/controllers/activitypub/client.ts | 16 |
1 files changed, 13 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) { |