aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-11 11:33:44 +0200
committerChocobozzz <me@florianbigard.com>2019-04-11 13:45:39 +0200
commit6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0 (patch)
treeb47de7efb8c6c611c63a15a971c6125a278f547a /server/controllers/activitypub
parent2c3abc4fa796555eb7d25f416c4f41ab3e3ad8ca (diff)
downloadPeerTube-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.ts19
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 @@
2import * as express from 'express' 2import * as express from 'express'
3import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' 3import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
4import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' 4import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
5import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' 5import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers'
6import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' 6import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send'
7import { audiencify, getAudience } from '../../lib/activitypub/audience' 7import { audiencify, getAudience } from '../../lib/activitypub/audience'
8import { buildCreateActivity } from '../../lib/activitypub/send/send-create' 8import { buildCreateActivity } from '../../lib/activitypub/send/send-create'
@@ -19,7 +19,6 @@ import { AccountModel } from '../../models/account/account'
19import { ActorModel } from '../../models/activitypub/actor' 19import { ActorModel } from '../../models/activitypub/actor'
20import { ActorFollowModel } from '../../models/activitypub/actor-follow' 20import { ActorFollowModel } from '../../models/activitypub/actor-follow'
21import { VideoModel } from '../../models/video/video' 21import { VideoModel } from '../../models/video/video'
22import { VideoChannelModel } from '../../models/video/video-channel'
23import { VideoCommentModel } from '../../models/video/video-comment' 22import { VideoCommentModel } from '../../models/video/video-comment'
24import { VideoShareModel } from '../../models/video/video-share' 23import { VideoShareModel } from '../../models/video/video-share'
25import { cacheRoute } from '../../middlewares/cache' 24import { cacheRoute } from '../../middlewares/cache'
@@ -35,11 +34,9 @@ import {
35import { VideoCaptionModel } from '../../models/video/video-caption' 34import { VideoCaptionModel } from '../../models/video/video-caption'
36import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' 35import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy'
37import { getServerActor } from '../../helpers/utils' 36import { getServerActor } from '../../helpers/utils'
38import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
39import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' 37import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike'
40import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' 38import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
41import { VideoPlaylistModel } from '../../models/video/video-playlist' 39import { VideoPlaylistModel } from '../../models/video/video-playlist'
42import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
43import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 40import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
44 41
45const activityPubClientRouter = express.Router() 42const 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) {
232async function videoAnnounceController (req: express.Request, res: express.Response) { 229async 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
306async function videoCommentController (req: express.Request, res: express.Response) { 303async 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
325async function videoRedundancyController (req: express.Request, res: express.Response) { 322async 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
372async function actorFollowers (req: express.Request, actor: ActorModel) { 369async 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
380async function actorPlaylists (req: express.Request, account: AccountModel) { 377async 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
388function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) { 385function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) {