aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
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
parent2c3abc4fa796555eb7d25f416c4f41ab3e3ad8ca (diff)
downloadPeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.gz
PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.zst
PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.zip
Move config in its own file
Diffstat (limited to 'server/lib')
-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
-rw-r--r--server/lib/avatar.ts3
-rw-r--r--server/lib/client-html.ts13
-rw-r--r--server/lib/emailer.ts43
-rw-r--r--server/lib/files-cache/videos-caption-cache.ts3
-rw-r--r--server/lib/files-cache/videos-preview-cache.ts3
-rw-r--r--server/lib/hls.ts3
-rw-r--r--server/lib/job-queue/handlers/activitypub-follow.ts4
-rw-r--r--server/lib/job-queue/handlers/video-import.ts5
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts3
-rw-r--r--server/lib/job-queue/job-queue.ts4
-rw-r--r--server/lib/notifier.ts2
-rw-r--r--server/lib/oauth-model.ts3
-rw-r--r--server/lib/redis.ts7
-rw-r--r--server/lib/schedulers/videos-redundancy-scheduler.ts7
-rw-r--r--server/lib/video-blacklist.ts2
-rw-r--r--server/lib/video-transcoding.ts7
21 files changed, 80 insertions, 65 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
diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts
index 021426a1a..a5316df4b 100644
--- a/server/lib/avatar.ts
+++ b/server/lib/avatar.ts
@@ -1,6 +1,6 @@
1import 'multer' 1import 'multer'
2import { sendUpdateActor } from './activitypub/send' 2import { sendUpdateActor } from './activitypub/send'
3import { AVATARS_SIZE, CONFIG, sequelizeTypescript } from '../initializers' 3import { AVATARS_SIZE, sequelizeTypescript } from '../initializers'
4import { updateActorAvatarInstance } from './activitypub' 4import { updateActorAvatarInstance } from './activitypub'
5import { processImage } from '../helpers/image-utils' 5import { processImage } from '../helpers/image-utils'
6import { AccountModel } from '../models/account/account' 6import { AccountModel } from '../models/account/account'
@@ -8,6 +8,7 @@ import { VideoChannelModel } from '../models/video/video-channel'
8import { extname, join } from 'path' 8import { extname, join } from 'path'
9import { retryTransactionWrapper } from '../helpers/database-utils' 9import { retryTransactionWrapper } from '../helpers/database-utils'
10import * as uuidv4 from 'uuid/v4' 10import * as uuidv4 from 'uuid/v4'
11import { CONFIG } from '../initializers/config'
11 12
12async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) { 13async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) {
13 const extension = extname(avatarPhysicalFile.filename) 14 const extension = extname(avatarPhysicalFile.filename)
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index 217f6a437..f8e1e456f 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' 2import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n'
3import { CONFIG, CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE } from '../initializers' 3import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, WEBSERVER } from '../initializers'
4import { join } from 'path' 4import { join } from 'path'
5import { escapeHTML } from '../helpers/core-utils' 5import { escapeHTML } from '../helpers/core-utils'
6import { VideoModel } from '../models/video/video' 6import { VideoModel } from '../models/video/video'
@@ -11,6 +11,7 @@ import { getActivityStreamDuration } from '../models/video/video-format-utils'
11import { AccountModel } from '../models/account/account' 11import { AccountModel } from '../models/account/account'
12import { VideoChannelModel } from '../models/video/video-channel' 12import { VideoChannelModel } from '../models/video/video-channel'
13import * as Bluebird from 'bluebird' 13import * as Bluebird from 'bluebird'
14import { CONFIG } from '../initializers/config'
14 15
15export class ClientHtml { 16export class ClientHtml {
16 17
@@ -106,7 +107,7 @@ export class ClientHtml {
106 107
107 // Save locale in cookies 108 // Save locale in cookies
108 res.cookie('clientLanguage', lang, { 109 res.cookie('clientLanguage', lang, {
109 secure: CONFIG.WEBSERVER.SCHEME === 'https', 110 secure: WEBSERVER.SCHEME === 'https',
110 sameSite: true, 111 sameSite: true,
111 maxAge: 1000 * 3600 * 24 * 90 // 3 months 112 maxAge: 1000 * 3600 * 24 * 90 // 3 months
112 }) 113 })
@@ -143,12 +144,12 @@ export class ClientHtml {
143 } 144 }
144 145
145 private static addVideoOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { 146 private static addVideoOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
146 const previewUrl = CONFIG.WEBSERVER.URL + video.getPreviewStaticPath() 147 const previewUrl = WEBSERVER.URL + video.getPreviewStaticPath()
147 const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() 148 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
148 149
149 const videoNameEscaped = escapeHTML(video.name) 150 const videoNameEscaped = escapeHTML(video.name)
150 const videoDescriptionEscaped = escapeHTML(video.description) 151 const videoDescriptionEscaped = escapeHTML(video.description)
151 const embedUrl = CONFIG.WEBSERVER.URL + video.getEmbedStaticPath() 152 const embedUrl = WEBSERVER.URL + video.getEmbedStaticPath()
152 153
153 const openGraphMetaTags = { 154 const openGraphMetaTags = {
154 'og:type': 'video', 155 'og:type': 'video',
@@ -180,7 +181,7 @@ export class ClientHtml {
180 const oembedLinkTags = [ 181 const oembedLinkTags = [
181 { 182 {
182 type: 'application/json+oembed', 183 type: 'application/json+oembed',
183 href: CONFIG.WEBSERVER.URL + '/services/oembed?url=' + encodeURIComponent(videoUrl), 184 href: WEBSERVER.URL + '/services/oembed?url=' + encodeURIComponent(videoUrl),
184 title: videoNameEscaped 185 title: videoNameEscaped
185 } 186 }
186 ] 187 ]
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index aa9083362..8c06e9751 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -1,7 +1,7 @@
1import { createTransport, Transporter } from 'nodemailer' 1import { createTransport, Transporter } from 'nodemailer'
2import { isTestInstance } from '../helpers/core-utils' 2import { isTestInstance } from '../helpers/core-utils'
3import { bunyanLogger, logger } from '../helpers/logger' 3import { bunyanLogger, logger } from '../helpers/logger'
4import { CONFIG } from '../initializers' 4import { CONFIG } from '../initializers/config'
5import { UserModel } from '../models/account/user' 5import { UserModel } from '../models/account/user'
6import { VideoModel } from '../models/video/video' 6import { VideoModel } from '../models/video/video'
7import { JobQueue } from './job-queue' 7import { JobQueue } from './job-queue'
@@ -12,6 +12,7 @@ import { VideoAbuseModel } from '../models/video/video-abuse'
12import { VideoBlacklistModel } from '../models/video/video-blacklist' 12import { VideoBlacklistModel } from '../models/video/video-blacklist'
13import { VideoImportModel } from '../models/video/video-import' 13import { VideoImportModel } from '../models/video/video-import'
14import { ActorFollowModel } from '../models/activitypub/actor-follow' 14import { ActorFollowModel } from '../models/activitypub/actor-follow'
15import { WEBSERVER } from '../initializers/constants'
15 16
16type SendEmailOptions = { 17type SendEmailOptions = {
17 to: string[] 18 to: string[]
@@ -91,7 +92,7 @@ class Emailer {
91 92
92 addNewVideoFromSubscriberNotification (to: string[], video: VideoModel) { 93 addNewVideoFromSubscriberNotification (to: string[], video: VideoModel) {
93 const channelName = video.VideoChannel.getDisplayName() 94 const channelName = video.VideoChannel.getDisplayName()
94 const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() 95 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
95 96
96 const text = `Hi dear user,\n\n` + 97 const text = `Hi dear user,\n\n` +
97 `Your subscription ${channelName} just published a new video: ${video.name}` + 98 `Your subscription ${channelName} just published a new video: ${video.name}` +
@@ -148,7 +149,7 @@ class Emailer {
148 } 149 }
149 150
150 myVideoPublishedNotification (to: string[], video: VideoModel) { 151 myVideoPublishedNotification (to: string[], video: VideoModel) {
151 const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() 152 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
152 153
153 const text = `Hi dear user,\n\n` + 154 const text = `Hi dear user,\n\n` +
154 `Your video ${video.name} has been published.` + 155 `Your video ${video.name} has been published.` +
@@ -168,7 +169,7 @@ class Emailer {
168 } 169 }
169 170
170 myVideoImportSuccessNotification (to: string[], videoImport: VideoImportModel) { 171 myVideoImportSuccessNotification (to: string[], videoImport: VideoImportModel) {
171 const videoUrl = CONFIG.WEBSERVER.URL + videoImport.Video.getWatchStaticPath() 172 const videoUrl = WEBSERVER.URL + videoImport.Video.getWatchStaticPath()
172 173
173 const text = `Hi dear user,\n\n` + 174 const text = `Hi dear user,\n\n` +
174 `Your video import ${videoImport.getTargetIdentifier()} is finished.` + 175 `Your video import ${videoImport.getTargetIdentifier()} is finished.` +
@@ -188,7 +189,7 @@ class Emailer {
188 } 189 }
189 190
190 myVideoImportErrorNotification (to: string[], videoImport: VideoImportModel) { 191 myVideoImportErrorNotification (to: string[], videoImport: VideoImportModel) {
191 const importUrl = CONFIG.WEBSERVER.URL + '/my-account/video-imports' 192 const importUrl = WEBSERVER.URL + '/my-account/video-imports'
192 193
193 const text = `Hi dear user,\n\n` + 194 const text = `Hi dear user,\n\n` +
194 `Your video import ${videoImport.getTargetIdentifier()} encountered an error.` + 195 `Your video import ${videoImport.getTargetIdentifier()} encountered an error.` +
@@ -210,7 +211,7 @@ class Emailer {
210 addNewCommentOnMyVideoNotification (to: string[], comment: VideoCommentModel) { 211 addNewCommentOnMyVideoNotification (to: string[], comment: VideoCommentModel) {
211 const accountName = comment.Account.getDisplayName() 212 const accountName = comment.Account.getDisplayName()
212 const video = comment.Video 213 const video = comment.Video
213 const commentUrl = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath() 214 const commentUrl = WEBSERVER.URL + comment.getCommentStaticPath()
214 215
215 const text = `Hi dear user,\n\n` + 216 const text = `Hi dear user,\n\n` +
216 `A new comment has been posted by ${accountName} on your video ${video.name}` + 217 `A new comment has been posted by ${accountName} on your video ${video.name}` +
@@ -232,7 +233,7 @@ class Emailer {
232 addNewCommentMentionNotification (to: string[], comment: VideoCommentModel) { 233 addNewCommentMentionNotification (to: string[], comment: VideoCommentModel) {
233 const accountName = comment.Account.getDisplayName() 234 const accountName = comment.Account.getDisplayName()
234 const video = comment.Video 235 const video = comment.Video
235 const commentUrl = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath() 236 const commentUrl = WEBSERVER.URL + comment.getCommentStaticPath()
236 237
237 const text = `Hi dear user,\n\n` + 238 const text = `Hi dear user,\n\n` +
238 `${accountName} mentioned you on video ${video.name}` + 239 `${accountName} mentioned you on video ${video.name}` +
@@ -252,10 +253,10 @@ class Emailer {
252 } 253 }
253 254
254 addVideoAbuseModeratorsNotification (to: string[], videoAbuse: VideoAbuseModel) { 255 addVideoAbuseModeratorsNotification (to: string[], videoAbuse: VideoAbuseModel) {
255 const videoUrl = CONFIG.WEBSERVER.URL + videoAbuse.Video.getWatchStaticPath() 256 const videoUrl = WEBSERVER.URL + videoAbuse.Video.getWatchStaticPath()
256 257
257 const text = `Hi,\n\n` + 258 const text = `Hi,\n\n` +
258 `${CONFIG.WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` + 259 `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` +
259 `Cheers,\n` + 260 `Cheers,\n` +
260 `PeerTube.` 261 `PeerTube.`
261 262
@@ -269,8 +270,8 @@ class Emailer {
269 } 270 }
270 271
271 addVideoAutoBlacklistModeratorsNotification (to: string[], video: VideoModel) { 272 addVideoAutoBlacklistModeratorsNotification (to: string[], video: VideoModel) {
272 const VIDEO_AUTO_BLACKLIST_URL = CONFIG.WEBSERVER.URL + '/admin/moderation/video-auto-blacklist/list' 273 const VIDEO_AUTO_BLACKLIST_URL = WEBSERVER.URL + '/admin/moderation/video-auto-blacklist/list'
273 const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() 274 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
274 275
275 const text = `Hi,\n\n` + 276 const text = `Hi,\n\n` +
276 `A recently added video was auto-blacklisted and requires moderator review before publishing.` + 277 `A recently added video was auto-blacklisted and requires moderator review before publishing.` +
@@ -293,13 +294,13 @@ class Emailer {
293 294
294 addNewUserRegistrationNotification (to: string[], user: UserModel) { 295 addNewUserRegistrationNotification (to: string[], user: UserModel) {
295 const text = `Hi,\n\n` + 296 const text = `Hi,\n\n` +
296 `User ${user.username} just registered on ${CONFIG.WEBSERVER.HOST} PeerTube instance.\n\n` + 297 `User ${user.username} just registered on ${WEBSERVER.HOST} PeerTube instance.\n\n` +
297 `Cheers,\n` + 298 `Cheers,\n` +
298 `PeerTube.` 299 `PeerTube.`
299 300
300 const emailPayload: EmailPayload = { 301 const emailPayload: EmailPayload = {
301 to, 302 to,
302 subject: '[PeerTube] New user registration on ' + CONFIG.WEBSERVER.HOST, 303 subject: '[PeerTube] New user registration on ' + WEBSERVER.HOST,
303 text 304 text
304 } 305 }
305 306
@@ -308,10 +309,10 @@ class Emailer {
308 309
309 addVideoBlacklistNotification (to: string[], videoBlacklist: VideoBlacklistModel) { 310 addVideoBlacklistNotification (to: string[], videoBlacklist: VideoBlacklistModel) {
310 const videoName = videoBlacklist.Video.name 311 const videoName = videoBlacklist.Video.name
311 const videoUrl = CONFIG.WEBSERVER.URL + videoBlacklist.Video.getWatchStaticPath() 312 const videoUrl = WEBSERVER.URL + videoBlacklist.Video.getWatchStaticPath()
312 313
313 const reasonString = videoBlacklist.reason ? ` for the following reason: ${videoBlacklist.reason}` : '' 314 const reasonString = videoBlacklist.reason ? ` for the following reason: ${videoBlacklist.reason}` : ''
314 const blockedString = `Your video ${videoName} (${videoUrl} on ${CONFIG.WEBSERVER.HOST} has been blacklisted${reasonString}.` 315 const blockedString = `Your video ${videoName} (${videoUrl} on ${WEBSERVER.HOST} has been blacklisted${reasonString}.`
315 316
316 const text = 'Hi,\n\n' + 317 const text = 'Hi,\n\n' +
317 blockedString + 318 blockedString +
@@ -329,10 +330,10 @@ class Emailer {
329 } 330 }
330 331
331 addVideoUnblacklistNotification (to: string[], video: VideoModel) { 332 addVideoUnblacklistNotification (to: string[], video: VideoModel) {
332 const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() 333 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
333 334
334 const text = 'Hi,\n\n' + 335 const text = 'Hi,\n\n' +
335 `Your video ${video.name} (${videoUrl}) on ${CONFIG.WEBSERVER.HOST} has been unblacklisted.` + 336 `Your video ${video.name} (${videoUrl}) on ${WEBSERVER.HOST} has been unblacklisted.` +
336 '\n\n' + 337 '\n\n' +
337 'Cheers,\n' + 338 'Cheers,\n' +
338 `PeerTube.` 339 `PeerTube.`
@@ -348,7 +349,7 @@ class Emailer {
348 349
349 addPasswordResetEmailJob (to: string, resetPasswordUrl: string) { 350 addPasswordResetEmailJob (to: string, resetPasswordUrl: string) {
350 const text = `Hi dear user,\n\n` + 351 const text = `Hi dear user,\n\n` +
351 `A reset password procedure for your account ${to} has been requested on ${CONFIG.WEBSERVER.HOST} ` + 352 `A reset password procedure for your account ${to} has been requested on ${WEBSERVER.HOST} ` +
352 `Please follow this link to reset it: ${resetPasswordUrl}\n\n` + 353 `Please follow this link to reset it: ${resetPasswordUrl}\n\n` +
353 `If you are not the person who initiated this request, please ignore this email.\n\n` + 354 `If you are not the person who initiated this request, please ignore this email.\n\n` +
354 `Cheers,\n` + 355 `Cheers,\n` +
@@ -365,7 +366,7 @@ class Emailer {
365 366
366 addVerifyEmailJob (to: string, verifyEmailUrl: string) { 367 addVerifyEmailJob (to: string, verifyEmailUrl: string) {
367 const text = `Welcome to PeerTube,\n\n` + 368 const text = `Welcome to PeerTube,\n\n` +
368 `To start using PeerTube on ${CONFIG.WEBSERVER.HOST} you must verify your email! ` + 369 `To start using PeerTube on ${WEBSERVER.HOST} you must verify your email! ` +
369 `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` + 370 `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` +
370 `If you are not the person who initiated this request, please ignore this email.\n\n` + 371 `If you are not the person who initiated this request, please ignore this email.\n\n` +
371 `Cheers,\n` + 372 `Cheers,\n` +
@@ -383,7 +384,7 @@ class Emailer {
383 addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) { 384 addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) {
384 const reasonString = reason ? ` for the following reason: ${reason}` : '' 385 const reasonString = reason ? ` for the following reason: ${reason}` : ''
385 const blockedWord = blocked ? 'blocked' : 'unblocked' 386 const blockedWord = blocked ? 'blocked' : 'unblocked'
386 const blockedString = `Your account ${user.username} on ${CONFIG.WEBSERVER.HOST} has been ${blockedWord}${reasonString}.` 387 const blockedString = `Your account ${user.username} on ${WEBSERVER.HOST} has been ${blockedWord}${reasonString}.`
387 388
388 const text = 'Hi,\n\n' + 389 const text = 'Hi,\n\n' +
389 blockedString + 390 blockedString +
@@ -428,7 +429,7 @@ class Emailer {
428 429
429 const fromDisplayName = options.fromDisplayName 430 const fromDisplayName = options.fromDisplayName
430 ? options.fromDisplayName 431 ? options.fromDisplayName
431 : CONFIG.WEBSERVER.HOST 432 : WEBSERVER.HOST
432 433
433 return this.transporter.sendMail({ 434 return this.transporter.sendMail({
434 from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`, 435 from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`,
diff --git a/server/lib/files-cache/videos-caption-cache.ts b/server/lib/files-cache/videos-caption-cache.ts
index fe5b441af..f5ccfe0a2 100644
--- a/server/lib/files-cache/videos-caption-cache.ts
+++ b/server/lib/files-cache/videos-caption-cache.ts
@@ -1,8 +1,9 @@
1import { join } from 'path' 1import { join } from 'path'
2import { FILES_CACHE, CONFIG } from '../../initializers' 2import { FILES_CACHE } from '../../initializers'
3import { VideoModel } from '../../models/video/video' 3import { VideoModel } from '../../models/video/video'
4import { VideoCaptionModel } from '../../models/video/video-caption' 4import { VideoCaptionModel } from '../../models/video/video-caption'
5import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' 5import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache'
6import { CONFIG } from '../../initializers/config'
6 7
7type GetPathParam = { videoId: string, language: string } 8type GetPathParam = { videoId: string, language: string }
8 9
diff --git a/server/lib/files-cache/videos-preview-cache.ts b/server/lib/files-cache/videos-preview-cache.ts
index 01cd3647e..192f99aec 100644
--- a/server/lib/files-cache/videos-preview-cache.ts
+++ b/server/lib/files-cache/videos-preview-cache.ts
@@ -1,7 +1,8 @@
1import { join } from 'path' 1import { join } from 'path'
2import { FILES_CACHE, CONFIG, STATIC_PATHS } from '../../initializers' 2import { FILES_CACHE, STATIC_PATHS } from '../../initializers'
3import { VideoModel } from '../../models/video/video' 3import { VideoModel } from '../../models/video/video'
4import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' 4import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache'
5import { CONFIG } from '../../initializers/config'
5 6
6class VideosPreviewCache extends AbstractVideoStaticFileCache <string> { 7class VideosPreviewCache extends AbstractVideoStaticFileCache <string> {
7 8
diff --git a/server/lib/hls.ts b/server/lib/hls.ts
index a9a96dd16..e804e7b3a 100644
--- a/server/lib/hls.ts
+++ b/server/lib/hls.ts
@@ -1,6 +1,6 @@
1import { VideoModel } from '../models/video/video' 1import { VideoModel } from '../models/video/video'
2import { basename, dirname, join } from 'path' 2import { basename, dirname, join } from 'path'
3import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers' 3import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers'
4import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' 4import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra'
5import { getVideoFileSize } from '../helpers/ffmpeg-utils' 5import { getVideoFileSize } from '../helpers/ffmpeg-utils'
6import { sha256 } from '../helpers/core-utils' 6import { sha256 } from '../helpers/core-utils'
@@ -10,6 +10,7 @@ import { doRequest, doRequestAndSaveToFile } from '../helpers/requests'
10import { generateRandomString } from '../helpers/utils' 10import { generateRandomString } from '../helpers/utils'
11import { flatten, uniq } from 'lodash' 11import { flatten, uniq } from 'lodash'
12import { VideoFileModel } from '../models/video/video-file' 12import { VideoFileModel } from '../models/video/video-file'
13import { CONFIG } from '../initializers/config'
13 14
14async function updateStreamingPlaylistsInfohashesIfNeeded () { 15async function updateStreamingPlaylistsInfohashesIfNeeded () {
15 const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion() 16 const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion()
diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts
index e7e5ff950..7c84aa937 100644
--- a/server/lib/job-queue/handlers/activitypub-follow.ts
+++ b/server/lib/job-queue/handlers/activitypub-follow.ts
@@ -1,6 +1,6 @@
1import * as Bull from 'bull' 1import * as Bull from 'bull'
2import { logger } from '../../../helpers/logger' 2import { logger } from '../../../helpers/logger'
3import { CONFIG, REMOTE_SCHEME, sequelizeTypescript } from '../../../initializers' 3import { REMOTE_SCHEME, sequelizeTypescript, WEBSERVER } from '../../../initializers'
4import { sendFollow } from '../../activitypub/send' 4import { sendFollow } from '../../activitypub/send'
5import { sanitizeHost } from '../../../helpers/core-utils' 5import { sanitizeHost } from '../../../helpers/core-utils'
6import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' 6import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger'
@@ -23,7 +23,7 @@ async function processActivityPubFollow (job: Bull.Job) {
23 logger.info('Processing ActivityPub follow in job %d.', job.id) 23 logger.info('Processing ActivityPub follow in job %d.', job.id)
24 24
25 let targetActor: ActorModel 25 let targetActor: ActorModel
26 if (!host || host === CONFIG.WEBSERVER.HOST) { 26 if (!host || host === WEBSERVER.HOST) {
27 targetActor = await ActorModel.loadLocalByName(payload.name) 27 targetActor = await ActorModel.loadLocalByName(payload.name)
28 } else { 28 } else {
29 const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP) 29 const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP)
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts
index c5fc1061c..732773efd 100644
--- a/server/lib/job-queue/handlers/video-import.ts
+++ b/server/lib/job-queue/handlers/video-import.ts
@@ -6,7 +6,7 @@ import { VideoImportState } from '../../../../shared/models/videos'
6import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 6import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
7import { extname, join } from 'path' 7import { extname, join } from 'path'
8import { VideoFileModel } from '../../../models/video/video-file' 8import { VideoFileModel } from '../../../models/video/video-file'
9import { CONFIG, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' 9import { PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers'
10import { downloadImage } from '../../../helpers/requests' 10import { downloadImage } from '../../../helpers/requests'
11import { VideoState } from '../../../../shared' 11import { VideoState } from '../../../../shared'
12import { JobQueue } from '../index' 12import { JobQueue } from '../index'
@@ -14,8 +14,9 @@ import { federateVideoIfNeeded } from '../../activitypub'
14import { VideoModel } from '../../../models/video/video' 14import { VideoModel } from '../../../models/video/video'
15import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' 15import { downloadWebTorrentVideo } from '../../../helpers/webtorrent'
16import { getSecureTorrentName } from '../../../helpers/utils' 16import { getSecureTorrentName } from '../../../helpers/utils'
17import { remove, move, stat } from 'fs-extra' 17import { move, remove, stat } from 'fs-extra'
18import { Notifier } from '../../notifier' 18import { Notifier } from '../../notifier'
19import { CONFIG } from '../../../initializers/config'
19 20
20type VideoImportYoutubeDLPayload = { 21type VideoImportYoutubeDLPayload = {
21 type: 'youtube-dl' 22 type: 'youtube-dl'
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 581ec283e..48cac517e 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -5,11 +5,12 @@ import { VideoModel } from '../../../models/video/video'
5import { JobQueue } from '../job-queue' 5import { JobQueue } from '../job-queue'
6import { federateVideoIfNeeded } from '../../activitypub' 6import { federateVideoIfNeeded } from '../../activitypub'
7import { retryTransactionWrapper } from '../../../helpers/database-utils' 7import { retryTransactionWrapper } from '../../../helpers/database-utils'
8import { CONFIG, sequelizeTypescript } from '../../../initializers' 8import { sequelizeTypescript } from '../../../initializers'
9import * as Bluebird from 'bluebird' 9import * as Bluebird from 'bluebird'
10import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' 10import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils'
11import { generateHlsPlaylist, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding' 11import { generateHlsPlaylist, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding'
12import { Notifier } from '../../notifier' 12import { Notifier } from '../../notifier'
13import { CONFIG } from '../../../initializers/config'
13 14
14export type VideoTranscodingPayload = { 15export type VideoTranscodingPayload = {
15 videoUUID: string 16 videoUUID: string
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts
index cee0941c7..1c2aa109d 100644
--- a/server/lib/job-queue/job-queue.ts
+++ b/server/lib/job-queue/job-queue.ts
@@ -2,7 +2,7 @@ import * as Bull from 'bull'
2import { JobState, JobType } from '../../../shared/models' 2import { JobState, JobType } from '../../../shared/models'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { Redis } from '../redis' 4import { Redis } from '../redis'
5import { CONFIG, JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS } from '../../initializers' 5import { JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers'
6import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' 6import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast'
7import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' 7import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher'
8import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' 8import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast'
@@ -68,7 +68,7 @@ class JobQueue {
68 if (this.initialized === true) return 68 if (this.initialized === true) return
69 this.initialized = true 69 this.initialized = true
70 70
71 this.jobRedisPrefix = 'bull-' + CONFIG.WEBSERVER.HOST 71 this.jobRedisPrefix = 'bull-' + WEBSERVER.HOST
72 const queueOptions = { 72 const queueOptions = {
73 prefix: this.jobRedisPrefix, 73 prefix: this.jobRedisPrefix,
74 redis: Redis.getRedisClient(), 74 redis: Redis.getRedisClient(),
diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts
index 91b71cc64..c1e63fa8f 100644
--- a/server/lib/notifier.ts
+++ b/server/lib/notifier.ts
@@ -6,7 +6,7 @@ import { UserNotificationModel } from '../models/account/user-notification'
6import { VideoCommentModel } from '../models/video/video-comment' 6import { VideoCommentModel } from '../models/video/video-comment'
7import { UserModel } from '../models/account/user' 7import { UserModel } from '../models/account/user'
8import { PeerTubeSocket } from './peertube-socket' 8import { PeerTubeSocket } from './peertube-socket'
9import { CONFIG } from '../initializers/constants' 9import { CONFIG } from '../initializers/config'
10import { VideoPrivacy, VideoState } from '../../shared/models/videos' 10import { VideoPrivacy, VideoState } from '../../shared/models/videos'
11import { VideoAbuseModel } from '../models/video/video-abuse' 11import { VideoAbuseModel } from '../models/video/video-abuse'
12import { VideoBlacklistModel } from '../models/video/video-blacklist' 12import { VideoBlacklistModel } from '../models/video/video-blacklist'
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts
index 5b4a2bcf9..eb0e63bc8 100644
--- a/server/lib/oauth-model.ts
+++ b/server/lib/oauth-model.ts
@@ -4,8 +4,9 @@ import { logger } from '../helpers/logger'
4import { UserModel } from '../models/account/user' 4import { UserModel } from '../models/account/user'
5import { OAuthClientModel } from '../models/oauth/oauth-client' 5import { OAuthClientModel } from '../models/oauth/oauth-client'
6import { OAuthTokenModel } from '../models/oauth/oauth-token' 6import { OAuthTokenModel } from '../models/oauth/oauth-token'
7import { CONFIG, CACHE } from '../initializers/constants' 7import { CACHE } from '../initializers/constants'
8import { Transaction } from 'sequelize' 8import { Transaction } from 'sequelize'
9import { CONFIG } from '../initializers/config'
9 10
10type TokenInfo = { accessToken: string, refreshToken: string, accessTokenExpiresAt: Date, refreshTokenExpiresAt: Date } 11type TokenInfo = { accessToken: string, refreshToken: string, accessTokenExpiresAt: Date, refreshTokenExpiresAt: Date }
11let accessTokenCache: { [ accessToken: string ]: OAuthTokenModel } = {} 12let accessTokenCache: { [ accessToken: string ]: OAuthTokenModel } = {}
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index d85dbe2b5..a7ec8c9df 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -3,12 +3,13 @@ import { createClient, RedisClient } from 'redis'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4import { generateRandomString } from '../helpers/utils' 4import { generateRandomString } from '../helpers/utils'
5import { 5import {
6 CONFIG,
7 CONTACT_FORM_LIFETIME, 6 CONTACT_FORM_LIFETIME,
8 USER_EMAIL_VERIFY_LIFETIME, 7 USER_EMAIL_VERIFY_LIFETIME,
9 USER_PASSWORD_RESET_LIFETIME, 8 USER_PASSWORD_RESET_LIFETIME,
10 VIDEO_VIEW_LIFETIME 9 VIDEO_VIEW_LIFETIME,
10 WEBSERVER
11} from '../initializers' 11} from '../initializers'
12import { CONFIG } from '../initializers/config'
12 13
13type CachedRoute = { 14type CachedRoute = {
14 body: string, 15 body: string,
@@ -41,7 +42,7 @@ class Redis {
41 this.client.auth(CONFIG.REDIS.AUTH) 42 this.client.auth(CONFIG.REDIS.AUTH)
42 } 43 }
43 44
44 this.prefix = 'redis-' + CONFIG.WEBSERVER.HOST + '-' 45 this.prefix = 'redis-' + WEBSERVER.HOST + '-'
45 } 46 }
46 47
47 static getRedisClient () { 48 static getRedisClient () {
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts
index 1a48f2bd0..4a8a1d413 100644
--- a/server/lib/schedulers/videos-redundancy-scheduler.ts
+++ b/server/lib/schedulers/videos-redundancy-scheduler.ts
@@ -1,5 +1,5 @@
1import { AbstractScheduler } from './abstract-scheduler' 1import { AbstractScheduler } from './abstract-scheduler'
2import { CONFIG, HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers' 2import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT, WEBSERVER } from '../../initializers'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { VideosRedundancy } from '../../../shared/models/redundancy' 4import { VideosRedundancy } from '../../../shared/models/redundancy'
5import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' 5import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
@@ -15,6 +15,7 @@ import { getOrCreateVideoAndAccountAndChannel } from '../activitypub'
15import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist' 15import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
16import { VideoModel } from '../../models/video/video' 16import { VideoModel } from '../../models/video/video'
17import { downloadPlaylistSegments } from '../hls' 17import { downloadPlaylistSegments } from '../hls'
18import { CONFIG } from '../../initializers/config'
18 19
19type CandidateToDuplicate = { 20type CandidateToDuplicate = {
20 redundancy: VideosRedundancy, 21 redundancy: VideosRedundancy,
@@ -186,7 +187,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
186 const createdModel = await VideoRedundancyModel.create({ 187 const createdModel = await VideoRedundancyModel.create({
187 expiresOn: this.buildNewExpiration(redundancy.minLifetime), 188 expiresOn: this.buildNewExpiration(redundancy.minLifetime),
188 url: getVideoCacheFileActivityPubUrl(file), 189 url: getVideoCacheFileActivityPubUrl(file),
189 fileUrl: video.getVideoRedundancyUrl(file, CONFIG.WEBSERVER.URL), 190 fileUrl: video.getVideoRedundancyUrl(file, WEBSERVER.URL),
190 strategy: redundancy.strategy, 191 strategy: redundancy.strategy,
191 videoFileId: file.id, 192 videoFileId: file.id,
192 actorId: serverActor.id 193 actorId: serverActor.id
@@ -212,7 +213,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
212 const createdModel = await VideoRedundancyModel.create({ 213 const createdModel = await VideoRedundancyModel.create({
213 expiresOn: this.buildNewExpiration(redundancy.minLifetime), 214 expiresOn: this.buildNewExpiration(redundancy.minLifetime),
214 url: getVideoCacheStreamingPlaylistActivityPubUrl(video, playlist), 215 url: getVideoCacheStreamingPlaylistActivityPubUrl(video, playlist),
215 fileUrl: playlist.getVideoRedundancyUrl(CONFIG.WEBSERVER.URL), 216 fileUrl: playlist.getVideoRedundancyUrl(WEBSERVER.URL),
216 strategy: redundancy.strategy, 217 strategy: redundancy.strategy,
217 videoStreamingPlaylistId: playlist.id, 218 videoStreamingPlaylistId: playlist.id,
218 actorId: serverActor.id 219 actorId: serverActor.id
diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts
index dc4e0aed9..a5c6fcbb2 100644
--- a/server/lib/video-blacklist.ts
+++ b/server/lib/video-blacklist.ts
@@ -1,5 +1,5 @@
1import * as sequelize from 'sequelize' 1import * as sequelize from 'sequelize'
2import { CONFIG } from '../initializers/constants' 2import { CONFIG } from '../initializers/config'
3import { VideoBlacklistType, UserRight } from '../../shared/models' 3import { VideoBlacklistType, UserRight } from '../../shared/models'
4import { VideoBlacklistModel } from '../models/video/video-blacklist' 4import { VideoBlacklistModel } from '../models/video/video-blacklist'
5import { UserModel } from '../models/account/user' 5import { UserModel } from '../models/account/user'
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts
index dbc22816c..11098dca3 100644
--- a/server/lib/video-transcoding.ts
+++ b/server/lib/video-transcoding.ts
@@ -1,4 +1,4 @@
1import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION } from '../initializers' 1import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers'
2import { join } from 'path' 2import { join } from 'path'
3import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' 3import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils'
4import { ensureDir, move, remove, stat } from 'fs-extra' 4import { ensureDir, move, remove, stat } from 'fs-extra'
@@ -9,6 +9,7 @@ import { VideoModel } from '../models/video/video'
9import { updateMasterHLSPlaylist, updateSha256Segments } from './hls' 9import { updateMasterHLSPlaylist, updateSha256Segments } from './hls'
10import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' 10import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
11import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' 11import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type'
12import { CONFIG } from '../initializers/config'
12 13
13async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { 14async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) {
14 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR 15 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR
@@ -111,12 +112,12 @@ async function generateHlsPlaylist (video: VideoModel, resolution: VideoResoluti
111 await updateMasterHLSPlaylist(video) 112 await updateMasterHLSPlaylist(video)
112 await updateSha256Segments(video) 113 await updateSha256Segments(video)
113 114
114 const playlistUrl = CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) 115 const playlistUrl = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid)
115 116
116 await VideoStreamingPlaylistModel.upsert({ 117 await VideoStreamingPlaylistModel.upsert({
117 videoId: video.id, 118 videoId: video.id,
118 playlistUrl, 119 playlistUrl,
119 segmentsSha256Url: CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid), 120 segmentsSha256Url: WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid),
120 p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, video.VideoFiles), 121 p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, video.VideoFiles),
121 p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, 122 p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION,
122 123