diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-11 11:33:44 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-11 13:45:39 +0200 |
commit | 6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0 (patch) | |
tree | b47de7efb8c6c611c63a15a971c6125a278f547a /server/controllers/activitypub | |
parent | 2c3abc4fa796555eb7d25f416c4f41ab3e3ad8ca (diff) | |
download | PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.gz PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.zst PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.zip |
Move config in its own file
Diffstat (limited to 'server/controllers/activitypub')
-rw-r--r-- | server/controllers/activitypub/client.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index e06aa35f4..f47fae766 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' | 3 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' |
4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' | 4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' |
5 | import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' | 5 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers' |
6 | import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' | 6 | import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' |
7 | import { audiencify, getAudience } from '../../lib/activitypub/audience' | 7 | import { audiencify, getAudience } from '../../lib/activitypub/audience' |
8 | import { buildCreateActivity } from '../../lib/activitypub/send/send-create' | 8 | import { buildCreateActivity } from '../../lib/activitypub/send/send-create' |
@@ -19,7 +19,6 @@ import { AccountModel } from '../../models/account/account' | |||
19 | import { ActorModel } from '../../models/activitypub/actor' | 19 | import { ActorModel } from '../../models/activitypub/actor' |
20 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | 20 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
21 | import { VideoModel } from '../../models/video/video' | 21 | import { VideoModel } from '../../models/video/video' |
22 | import { VideoChannelModel } from '../../models/video/video-channel' | ||
23 | import { VideoCommentModel } from '../../models/video/video-comment' | 22 | import { VideoCommentModel } from '../../models/video/video-comment' |
24 | import { VideoShareModel } from '../../models/video/video-share' | 23 | import { VideoShareModel } from '../../models/video/video-share' |
25 | import { cacheRoute } from '../../middlewares/cache' | 24 | import { cacheRoute } from '../../middlewares/cache' |
@@ -35,11 +34,9 @@ import { | |||
35 | import { VideoCaptionModel } from '../../models/video/video-caption' | 34 | import { VideoCaptionModel } from '../../models/video/video-caption' |
36 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' | 35 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' |
37 | import { getServerActor } from '../../helpers/utils' | 36 | import { getServerActor } from '../../helpers/utils' |
38 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | ||
39 | import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' | 37 | import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' |
40 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' | 38 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' |
41 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 39 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
42 | import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' | ||
43 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | 40 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' |
44 | 41 | ||
45 | const activityPubClientRouter = express.Router() | 42 | const activityPubClientRouter = express.Router() |
@@ -213,7 +210,7 @@ async function videoController (req: express.Request, res: express.Response) { | |||
213 | // We need more attributes | 210 | // We need more attributes |
214 | const video = await VideoModel.loadForGetAPI(res.locals.video.id) | 211 | const video = await VideoModel.loadForGetAPI(res.locals.video.id) |
215 | 212 | ||
216 | if (video.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(video.url) | 213 | if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url) |
217 | 214 | ||
218 | // We need captions to render AP object | 215 | // We need captions to render AP object |
219 | video.VideoCaptions = await VideoCaptionModel.listVideoCaptions(video.id) | 216 | video.VideoCaptions = await VideoCaptionModel.listVideoCaptions(video.id) |
@@ -232,7 +229,7 @@ async function videoController (req: express.Request, res: express.Response) { | |||
232 | async function videoAnnounceController (req: express.Request, res: express.Response) { | 229 | async function videoAnnounceController (req: express.Request, res: express.Response) { |
233 | const share = res.locals.videoShare | 230 | const share = res.locals.videoShare |
234 | 231 | ||
235 | if (share.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(share.url) | 232 | if (share.url.startsWith(WEBSERVER.URL) === false) return res.redirect(share.url) |
236 | 233 | ||
237 | const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.video, undefined) | 234 | const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.video, undefined) |
238 | 235 | ||
@@ -306,7 +303,7 @@ async function videoChannelFollowingController (req: express.Request, res: expre | |||
306 | async function videoCommentController (req: express.Request, res: express.Response) { | 303 | async function videoCommentController (req: express.Request, res: express.Response) { |
307 | const videoComment = res.locals.videoComment | 304 | const videoComment = res.locals.videoComment |
308 | 305 | ||
309 | if (videoComment.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoComment.url) | 306 | if (videoComment.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoComment.url) |
310 | 307 | ||
311 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined) | 308 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined) |
312 | const isPublic = true // Comments are always public | 309 | const isPublic = true // Comments are always public |
@@ -324,7 +321,7 @@ async function videoCommentController (req: express.Request, res: express.Respon | |||
324 | 321 | ||
325 | async function videoRedundancyController (req: express.Request, res: express.Response) { | 322 | async function videoRedundancyController (req: express.Request, res: express.Response) { |
326 | const videoRedundancy = res.locals.videoRedundancy | 323 | const videoRedundancy = res.locals.videoRedundancy |
327 | if (videoRedundancy.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url) | 324 | if (videoRedundancy.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url) |
328 | 325 | ||
329 | const serverActor = await getServerActor() | 326 | const serverActor = await getServerActor() |
330 | 327 | ||
@@ -366,7 +363,7 @@ async function actorFollowing (req: express.Request, actor: ActorModel) { | |||
366 | return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count) | 363 | return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count) |
367 | } | 364 | } |
368 | 365 | ||
369 | return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page) | 366 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) |
370 | } | 367 | } |
371 | 368 | ||
372 | async function actorFollowers (req: express.Request, actor: ActorModel) { | 369 | async function actorFollowers (req: express.Request, actor: ActorModel) { |
@@ -374,7 +371,7 @@ async function actorFollowers (req: express.Request, actor: ActorModel) { | |||
374 | return ActorFollowModel.listAcceptedFollowerUrlsForAP([ actor.id ], undefined, start, count) | 371 | return ActorFollowModel.listAcceptedFollowerUrlsForAP([ actor.id ], undefined, start, count) |
375 | } | 372 | } |
376 | 373 | ||
377 | return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page) | 374 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) |
378 | } | 375 | } |
379 | 376 | ||
380 | async function actorPlaylists (req: express.Request, account: AccountModel) { | 377 | async function actorPlaylists (req: express.Request, account: AccountModel) { |
@@ -382,7 +379,7 @@ async function actorPlaylists (req: express.Request, account: AccountModel) { | |||
382 | return VideoPlaylistModel.listPublicUrlsOfForAP(account.id, start, count) | 379 | return VideoPlaylistModel.listPublicUrlsOfForAP(account.id, start, count) |
383 | } | 380 | } |
384 | 381 | ||
385 | return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page) | 382 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) |
386 | } | 383 | } |
387 | 384 | ||
388 | function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) { | 385 | function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) { |