diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/actor.ts | 5 | ||||
-rw-r--r-- | server/lib/activitypub/playlist.ts | 3 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-follow.ts | 3 | ||||
-rw-r--r-- | server/lib/activitypub/url.ts | 20 | ||||
-rw-r--r-- | server/lib/activitypub/videos.ts | 2 |
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' | |||
12 | import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' | 12 | import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' |
13 | import { doRequest, downloadImage } from '../../helpers/requests' | 13 | import { doRequest, downloadImage } from '../../helpers/requests' |
14 | import { getUrlFromWebfinger } from '../../helpers/webfinger' | 14 | import { getUrlFromWebfinger } from '../../helpers/webfinger' |
15 | import { AVATARS_SIZE, CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers' | 15 | import { AVATARS_SIZE, MIMETYPES, sequelizeTypescript, WEBSERVER } from '../../initializers' |
16 | import { AccountModel } from '../../models/account/account' | 16 | import { AccountModel } from '../../models/account/account' |
17 | import { ActorModel } from '../../models/activitypub/actor' | 17 | import { ActorModel } from '../../models/activitypub/actor' |
18 | import { AvatarModel } from '../../models/avatar/avatar' | 18 | import { AvatarModel } from '../../models/avatar/avatar' |
@@ -21,6 +21,7 @@ import { VideoChannelModel } from '../../models/video/video-channel' | |||
21 | import { JobQueue } from '../job-queue' | 21 | import { JobQueue } from '../job-queue' |
22 | import { getServerActor } from '../../helpers/utils' | 22 | import { getServerActor } from '../../helpers/utils' |
23 | import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' | 23 | import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' |
24 | import { 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 |
26 | function setAsyncActorKeys (actor: ActorModel) { | 27 | function 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 @@ | |||
1 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' | 1 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' |
2 | import { crawlCollectionPage } from './crawl' | 2 | import { crawlCollectionPage } from './crawl' |
3 | import { ACTIVITY_PUB, CONFIG, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers' | 3 | import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers' |
4 | import { AccountModel } from '../../models/account/account' | 4 | import { AccountModel } from '../../models/account/account' |
5 | import { isArray } from '../../helpers/custom-validators/misc' | 5 | import { isArray } from '../../helpers/custom-validators/misc' |
6 | import { getOrCreateActorAndServerAndModel } from './actor' | 6 | import { getOrCreateActorAndServerAndModel } from './actor' |
@@ -17,6 +17,7 @@ import { VideoModel } from '../../models/video/video' | |||
17 | import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' | 17 | import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' |
18 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | 18 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' |
19 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' | 19 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' |
20 | import { CONFIG } from '../../initializers/config' | ||
20 | 21 | ||
21 | function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: AccountModel, to: string[]) { | 22 | function 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 @@ | |||
1 | import { ActivityFollow } from '../../../../shared/models/activitypub' | 1 | import { ActivityFollow } from '../../../../shared/models/activitypub' |
2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { sequelizeTypescript, CONFIG } from '../../../initializers' | 4 | import { sequelizeTypescript } from '../../../initializers' |
5 | import { ActorModel } from '../../../models/activitypub/actor' | 5 | import { ActorModel } from '../../../models/activitypub/actor' |
6 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 6 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
7 | import { sendAccept, sendReject } from '../send' | 7 | import { sendAccept, sendReject } from '../send' |
8 | import { Notifier } from '../../notifier' | 8 | import { Notifier } from '../../notifier' |
9 | import { getAPId } from '../../../helpers/activitypub' | 9 | import { getAPId } from '../../../helpers/activitypub' |
10 | import { getServerActor } from '../../../helpers/utils' | 10 | import { getServerActor } from '../../../helpers/utils' |
11 | import { CONFIG } from '../../../initializers/config' | ||
11 | 12 | ||
12 | async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) { | 13 | async 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 @@ | |||
1 | import { CONFIG } from '../../initializers' | 1 | import { WEBSERVER } from '../../initializers' |
2 | import { ActorModel } from '../../models/activitypub/actor' | 2 | import { ActorModel } from '../../models/activitypub/actor' |
3 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | 3 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
4 | import { VideoModel } from '../../models/video/video' | 4 | import { VideoModel } from '../../models/video/video' |
@@ -9,41 +9,41 @@ import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming- | |||
9 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 9 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
10 | 10 | ||
11 | function getVideoActivityPubUrl (video: VideoModel) { | 11 | function getVideoActivityPubUrl (video: VideoModel) { |
12 | return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid | 12 | return WEBSERVER.URL + '/videos/watch/' + video.uuid |
13 | } | 13 | } |
14 | 14 | ||
15 | function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) { | 15 | function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) { |
16 | return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid | 16 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid |
17 | } | 17 | } |
18 | 18 | ||
19 | function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) { | 19 | function 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 | ||
23 | function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) { | 23 | function 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 | ||
29 | function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { | 29 | function 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 | ||
33 | function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { | 33 | function 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 | ||
37 | function getVideoChannelActivityPubUrl (videoChannelName: string) { | 37 | function getVideoChannelActivityPubUrl (videoChannelName: string) { |
38 | return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName | 38 | return WEBSERVER.URL + '/video-channels/' + videoChannelName |
39 | } | 39 | } |
40 | 40 | ||
41 | function getAccountActivityPubUrl (accountName: string) { | 41 | function getAccountActivityPubUrl (accountName: string) { |
42 | return CONFIG.WEBSERVER.URL + '/accounts/' + accountName | 42 | return WEBSERVER.URL + '/accounts/' + accountName |
43 | } | 43 | } |
44 | 44 | ||
45 | function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) { | 45 | function 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 | ||
49 | function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) { | 49 | function 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' | |||
19 | import { doRequest, downloadImage } from '../../helpers/requests' | 19 | import { doRequest, downloadImage } from '../../helpers/requests' |
20 | import { | 20 | import { |
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' | |||
51 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' | 50 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' |
52 | import { VideoShareModel } from '../../models/video/video-share' | 51 | import { VideoShareModel } from '../../models/video/video-share' |
53 | import { VideoCommentModel } from '../../models/video/video-comment' | 52 | import { VideoCommentModel } from '../../models/video/video-comment' |
53 | import { CONFIG } from '../../initializers/config' | ||
54 | 54 | ||
55 | async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { | 55 | async 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 |