From 6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Apr 2019 11:33:44 +0200 Subject: Move config in its own file --- server/lib/activitypub/actor.ts | 5 +++-- server/lib/activitypub/playlist.ts | 3 ++- server/lib/activitypub/process/process-follow.ts | 3 ++- server/lib/activitypub/url.ts | 20 ++++++++++---------- server/lib/activitypub/videos.ts | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) (limited to 'server/lib/activitypub') 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' import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' import { doRequest, downloadImage } from '../../helpers/requests' import { getUrlFromWebfinger } from '../../helpers/webfinger' -import { AVATARS_SIZE, CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers' +import { AVATARS_SIZE, MIMETYPES, sequelizeTypescript, WEBSERVER } from '../../initializers' import { AccountModel } from '../../models/account/account' import { ActorModel } from '../../models/activitypub/actor' import { AvatarModel } from '../../models/avatar/avatar' @@ -21,6 +21,7 @@ import { VideoChannelModel } from '../../models/video/video-channel' import { JobQueue } from '../job-queue' import { getServerActor } from '../../helpers/utils' import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' +import { CONFIG } from '../../initializers/config' // Set account keys, this could be long so process after the account creation and do not block the client function setAsyncActorKeys (actor: ActorModel) { @@ -116,7 +117,7 @@ function buildActorInstance (type: ActivityPubActorType, url: string, preferredU followingCount: 0, inboxUrl: url + '/inbox', outboxUrl: url + '/outbox', - sharedInboxUrl: CONFIG.WEBSERVER.URL + '/inbox', + sharedInboxUrl: WEBSERVER.URL + '/inbox', followersUrl: url + '/followers', followingUrl: url + '/following' }) 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 @@ import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' import { crawlCollectionPage } from './crawl' -import { ACTIVITY_PUB, CONFIG, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers' +import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers' import { AccountModel } from '../../models/account/account' import { isArray } from '../../helpers/custom-validators/misc' import { getOrCreateActorAndServerAndModel } from './actor' @@ -17,6 +17,7 @@ import { VideoModel } from '../../models/video/video' import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' import { ActivityIconObject } from '../../../shared/models/activitypub/objects' +import { CONFIG } from '../../initializers/config' function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: AccountModel, to: string[]) { 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 @@ import { ActivityFollow } from '../../../../shared/models/activitypub' import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' -import { sequelizeTypescript, CONFIG } from '../../../initializers' +import { sequelizeTypescript } from '../../../initializers' import { ActorModel } from '../../../models/activitypub/actor' import { ActorFollowModel } from '../../../models/activitypub/actor-follow' import { sendAccept, sendReject } from '../send' import { Notifier } from '../../notifier' import { getAPId } from '../../../helpers/activitypub' import { getServerActor } from '../../../helpers/utils' +import { CONFIG } from '../../../initializers/config' async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) { 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 @@ -import { CONFIG } from '../../initializers' +import { WEBSERVER } from '../../initializers' import { ActorModel } from '../../models/activitypub/actor' import { ActorFollowModel } from '../../models/activitypub/actor-follow' import { VideoModel } from '../../models/video/video' @@ -9,41 +9,41 @@ import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming- import { VideoPlaylistModel } from '../../models/video/video-playlist' function getVideoActivityPubUrl (video: VideoModel) { - return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + return WEBSERVER.URL + '/videos/watch/' + video.uuid } function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) { - return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid } function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) { - return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid + return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid } function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) { const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' - return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` + return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` } function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { - return `${CONFIG.WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` + return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` } function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { - return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id + return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id } function getVideoChannelActivityPubUrl (videoChannelName: string) { - return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName + return WEBSERVER.URL + '/video-channels/' + videoChannelName } function getAccountActivityPubUrl (accountName: string) { - return CONFIG.WEBSERVER.URL + '/accounts/' + accountName + return WEBSERVER.URL + '/accounts/' + accountName } function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) { - return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id + return WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id } 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' import { doRequest, downloadImage } from '../../helpers/requests' import { ACTIVITY_PUB, - CONFIG, MIMETYPES, P2P_MEDIA_LOADER_PEER_VERSION, REMOTE_SCHEME, @@ -51,6 +50,7 @@ import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' import { AccountVideoRateModel } from '../../models/account/account-video-rate' import { VideoShareModel } from '../../models/video/video-share' import { VideoCommentModel } from '../../models/video/video-comment' +import { CONFIG } from '../../initializers/config' async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { // If the video is not private and is published, we federate it -- cgit v1.2.3