aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/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/lib/activitypub
parent2c3abc4fa796555eb7d25f416c4f41ab3e3ad8ca (diff)
downloadPeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.gz
PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.zst
PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.zip
Move config in its own file
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/actor.ts5
-rw-r--r--server/lib/activitypub/playlist.ts3
-rw-r--r--server/lib/activitypub/process/process-follow.ts3
-rw-r--r--server/lib/activitypub/url.ts20
-rw-r--r--server/lib/activitypub/videos.ts2
5 files changed, 18 insertions, 15 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index c0ad07a52..cfefc26ce 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -12,7 +12,7 @@ import { logger } from '../../helpers/logger'
12import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' 12import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto'
13import { doRequest, downloadImage } from '../../helpers/requests' 13import { doRequest, downloadImage } from '../../helpers/requests'
14import { getUrlFromWebfinger } from '../../helpers/webfinger' 14import { getUrlFromWebfinger } from '../../helpers/webfinger'
15import { AVATARS_SIZE, CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers' 15import { AVATARS_SIZE, MIMETYPES, sequelizeTypescript, WEBSERVER } from '../../initializers'
16import { AccountModel } from '../../models/account/account' 16import { AccountModel } from '../../models/account/account'
17import { ActorModel } from '../../models/activitypub/actor' 17import { ActorModel } from '../../models/activitypub/actor'
18import { AvatarModel } from '../../models/avatar/avatar' 18import { AvatarModel } from '../../models/avatar/avatar'
@@ -21,6 +21,7 @@ import { VideoChannelModel } from '../../models/video/video-channel'
21import { JobQueue } from '../job-queue' 21import { JobQueue } from '../job-queue'
22import { getServerActor } from '../../helpers/utils' 22import { getServerActor } from '../../helpers/utils'
23import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' 23import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor'
24import { CONFIG } from '../../initializers/config'
24 25
25// Set account keys, this could be long so process after the account creation and do not block the client 26// Set account keys, this could be long so process after the account creation and do not block the client
26function setAsyncActorKeys (actor: ActorModel) { 27function setAsyncActorKeys (actor: ActorModel) {
@@ -116,7 +117,7 @@ function buildActorInstance (type: ActivityPubActorType, url: string, preferredU
116 followingCount: 0, 117 followingCount: 0,
117 inboxUrl: url + '/inbox', 118 inboxUrl: url + '/inbox',
118 outboxUrl: url + '/outbox', 119 outboxUrl: url + '/outbox',
119 sharedInboxUrl: CONFIG.WEBSERVER.URL + '/inbox', 120 sharedInboxUrl: WEBSERVER.URL + '/inbox',
120 followersUrl: url + '/followers', 121 followersUrl: url + '/followers',
121 followingUrl: url + '/following' 122 followingUrl: url + '/following'
122 }) 123 })
diff --git a/server/lib/activitypub/playlist.ts b/server/lib/activitypub/playlist.ts
index c4a8f12ec..a0d0e736e 100644
--- a/server/lib/activitypub/playlist.ts
+++ b/server/lib/activitypub/playlist.ts
@@ -1,6 +1,6 @@
1import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' 1import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'
2import { crawlCollectionPage } from './crawl' 2import { crawlCollectionPage } from './crawl'
3import { ACTIVITY_PUB, CONFIG, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers' 3import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers'
4import { AccountModel } from '../../models/account/account' 4import { AccountModel } from '../../models/account/account'
5import { isArray } from '../../helpers/custom-validators/misc' 5import { isArray } from '../../helpers/custom-validators/misc'
6import { getOrCreateActorAndServerAndModel } from './actor' 6import { getOrCreateActorAndServerAndModel } from './actor'
@@ -17,6 +17,7 @@ import { VideoModel } from '../../models/video/video'
17import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' 17import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
18import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 18import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
19import { ActivityIconObject } from '../../../shared/models/activitypub/objects' 19import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
20import { CONFIG } from '../../initializers/config'
20 21
21function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: AccountModel, to: string[]) { 22function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: AccountModel, to: string[]) {
22 const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPlaylistPrivacy.PUBLIC : VideoPlaylistPrivacy.UNLISTED 23 const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPlaylistPrivacy.PUBLIC : VideoPlaylistPrivacy.UNLISTED
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts
index 276a57e60..ac3dd6ac4 100644
--- a/server/lib/activitypub/process/process-follow.ts
+++ b/server/lib/activitypub/process/process-follow.ts
@@ -1,13 +1,14 @@
1import { ActivityFollow } from '../../../../shared/models/activitypub' 1import { ActivityFollow } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers/database-utils' 2import { retryTransactionWrapper } from '../../../helpers/database-utils'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { sequelizeTypescript, CONFIG } from '../../../initializers' 4import { sequelizeTypescript } from '../../../initializers'
5import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
6import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 6import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
7import { sendAccept, sendReject } from '../send' 7import { sendAccept, sendReject } from '../send'
8import { Notifier } from '../../notifier' 8import { Notifier } from '../../notifier'
9import { getAPId } from '../../../helpers/activitypub' 9import { getAPId } from '../../../helpers/activitypub'
10import { getServerActor } from '../../../helpers/utils' 10import { getServerActor } from '../../../helpers/utils'
11import { CONFIG } from '../../../initializers/config'
11 12
12async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) { 13async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) {
13 const activityObject = getAPId(activity.object) 14 const activityObject = getAPId(activity.object)
diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts
index 401b83fc2..01950a13b 100644
--- a/server/lib/activitypub/url.ts
+++ b/server/lib/activitypub/url.ts
@@ -1,4 +1,4 @@
1import { CONFIG } from '../../initializers' 1import { WEBSERVER } from '../../initializers'
2import { ActorModel } from '../../models/activitypub/actor' 2import { ActorModel } from '../../models/activitypub/actor'
3import { ActorFollowModel } from '../../models/activitypub/actor-follow' 3import { ActorFollowModel } from '../../models/activitypub/actor-follow'
4import { VideoModel } from '../../models/video/video' 4import { VideoModel } from '../../models/video/video'
@@ -9,41 +9,41 @@ import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-
9import { VideoPlaylistModel } from '../../models/video/video-playlist' 9import { VideoPlaylistModel } from '../../models/video/video-playlist'
10 10
11function getVideoActivityPubUrl (video: VideoModel) { 11function getVideoActivityPubUrl (video: VideoModel) {
12 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid 12 return WEBSERVER.URL + '/videos/watch/' + video.uuid
13} 13}
14 14
15function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) { 15function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) {
16 return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid 16 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
17} 17}
18 18
19function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) { 19function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) {
20 return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid 20 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid
21} 21}
22 22
23function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) { 23function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
24 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' 24 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
25 25
26 return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` 26 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
27} 27}
28 28
29function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { 29function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) {
30 return `${CONFIG.WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` 30 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
31} 31}
32 32
33function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { 33function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
34 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id 34 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
35} 35}
36 36
37function getVideoChannelActivityPubUrl (videoChannelName: string) { 37function getVideoChannelActivityPubUrl (videoChannelName: string) {
38 return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName 38 return WEBSERVER.URL + '/video-channels/' + videoChannelName
39} 39}
40 40
41function getAccountActivityPubUrl (accountName: string) { 41function getAccountActivityPubUrl (accountName: string) {
42 return CONFIG.WEBSERVER.URL + '/accounts/' + accountName 42 return WEBSERVER.URL + '/accounts/' + accountName
43} 43}
44 44
45function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) { 45function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
46 return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id 46 return WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
47} 47}
48 48
49function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) { 49function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index caff0621e..191f4817b 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -19,7 +19,6 @@ import { logger } from '../../helpers/logger'
19import { doRequest, downloadImage } from '../../helpers/requests' 19import { doRequest, downloadImage } from '../../helpers/requests'
20import { 20import {
21 ACTIVITY_PUB, 21 ACTIVITY_PUB,
22 CONFIG,
23 MIMETYPES, 22 MIMETYPES,
24 P2P_MEDIA_LOADER_PEER_VERSION, 23 P2P_MEDIA_LOADER_PEER_VERSION,
25 REMOTE_SCHEME, 24 REMOTE_SCHEME,
@@ -51,6 +50,7 @@ import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
51import { AccountVideoRateModel } from '../../models/account/account-video-rate' 50import { AccountVideoRateModel } from '../../models/account/account-video-rate'
52import { VideoShareModel } from '../../models/video/video-share' 51import { VideoShareModel } from '../../models/video/video-share'
53import { VideoCommentModel } from '../../models/video/video-comment' 52import { VideoCommentModel } from '../../models/video/video-comment'
53import { CONFIG } from '../../initializers/config'
54 54
55async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { 55async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) {
56 // If the video is not private and is published, we federate it 56 // If the video is not private and is published, we federate it