diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-11 11:33:44 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-11 13:45:39 +0200 |
commit | 6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0 (patch) | |
tree | b47de7efb8c6c611c63a15a971c6125a278f547a /server | |
parent | 2c3abc4fa796555eb7d25f416c4f41ab3e3ad8ca (diff) | |
download | PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.gz PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.zst PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.zip |
Move config in its own file
Diffstat (limited to 'server')
79 files changed, 523 insertions, 458 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 @@ | |||
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' | 3 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' |
4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' | 4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' |
5 | import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' | 5 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers' |
6 | import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' | 6 | import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' |
7 | import { audiencify, getAudience } from '../../lib/activitypub/audience' | 7 | import { audiencify, getAudience } from '../../lib/activitypub/audience' |
8 | import { buildCreateActivity } from '../../lib/activitypub/send/send-create' | 8 | import { buildCreateActivity } from '../../lib/activitypub/send/send-create' |
@@ -19,7 +19,6 @@ import { AccountModel } from '../../models/account/account' | |||
19 | import { ActorModel } from '../../models/activitypub/actor' | 19 | import { ActorModel } from '../../models/activitypub/actor' |
20 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | 20 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
21 | import { VideoModel } from '../../models/video/video' | 21 | import { VideoModel } from '../../models/video/video' |
22 | import { VideoChannelModel } from '../../models/video/video-channel' | ||
23 | import { VideoCommentModel } from '../../models/video/video-comment' | 22 | import { VideoCommentModel } from '../../models/video/video-comment' |
24 | import { VideoShareModel } from '../../models/video/video-share' | 23 | import { VideoShareModel } from '../../models/video/video-share' |
25 | import { cacheRoute } from '../../middlewares/cache' | 24 | import { cacheRoute } from '../../middlewares/cache' |
@@ -35,11 +34,9 @@ import { | |||
35 | import { VideoCaptionModel } from '../../models/video/video-caption' | 34 | import { VideoCaptionModel } from '../../models/video/video-caption' |
36 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' | 35 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' |
37 | import { getServerActor } from '../../helpers/utils' | 36 | import { getServerActor } from '../../helpers/utils' |
38 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | ||
39 | import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' | 37 | import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' |
40 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' | 38 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' |
41 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 39 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
42 | import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' | ||
43 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | 40 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' |
44 | 41 | ||
45 | const activityPubClientRouter = express.Router() | 42 | const 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) { | |||
232 | async function videoAnnounceController (req: express.Request, res: express.Response) { | 229 | async 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 | |||
306 | async function videoCommentController (req: express.Request, res: express.Response) { | 303 | async 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 | ||
325 | async function videoRedundancyController (req: express.Request, res: express.Response) { | 322 | async 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 | ||
372 | async function actorFollowers (req: express.Request, actor: ActorModel) { | 369 | async 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 | ||
380 | async function actorPlaylists (req: express.Request, account: AccountModel) { | 377 | async 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 | ||
388 | function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) { | 385 | function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) { |
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 0d7fc8625..cdbccaa7d 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -4,7 +4,7 @@ import { ServerConfig, UserRight } from '../../../shared' | |||
4 | import { About } from '../../../shared/models/server/about.model' | 4 | import { About } from '../../../shared/models/server/about.model' |
5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' | 5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' |
6 | import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' | 6 | import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' |
7 | import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' | 7 | import { CONSTRAINTS_FIELDS } from '../../initializers' |
8 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' | 8 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' |
9 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' | 9 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' |
10 | import { ClientHtml } from '../../lib/client-html' | 10 | import { ClientHtml } from '../../lib/client-html' |
@@ -14,6 +14,7 @@ import { getServerCommit } from '../../helpers/utils' | |||
14 | import { Emailer } from '../../lib/emailer' | 14 | import { Emailer } from '../../lib/emailer' |
15 | import { isNumeric } from 'validator' | 15 | import { isNumeric } from 'validator' |
16 | import { objectConverter } from '../../helpers/core-utils' | 16 | import { objectConverter } from '../../helpers/core-utils' |
17 | import { CONFIG, reloadConfig } from '../../initializers/config' | ||
17 | 18 | ||
18 | const packageJSON = require('../../../../package.json') | 19 | const packageJSON = require('../../../../package.json') |
19 | const configRouter = express.Router() | 20 | const configRouter = express.Router() |
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts index 3dcc023e6..b2de8bcf5 100644 --- a/server/controllers/api/oauth-clients.ts +++ b/server/controllers/api/oauth-clients.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { OAuthClientLocal } from '../../../shared' | 2 | import { OAuthClientLocal } from '../../../shared' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { CONFIG } from '../../initializers' | 4 | import { CONFIG } from '../../initializers/config' |
5 | import { asyncMiddleware } from '../../middlewares' | 5 | import { asyncMiddleware } from '../../middlewares' |
6 | import { OAuthClientModel } from '../../models/oauth/oauth-client' | 6 | import { OAuthClientModel } from '../../models/oauth/oauth-client' |
7 | 7 | ||
diff --git a/server/controllers/api/server/logs.ts b/server/controllers/api/server/logs.ts index 5fa3c8787..bbbfa1d80 100644 --- a/server/controllers/api/server/logs.ts +++ b/server/controllers/api/server/logs.ts | |||
@@ -3,10 +3,11 @@ import { UserRight } from '../../../../shared/models/users' | |||
3 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' | 3 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' |
4 | import { mtimeSortFilesDesc } from '../../../../shared/utils/logs/logs' | 4 | import { mtimeSortFilesDesc } from '../../../../shared/utils/logs/logs' |
5 | import { readdir, readFile } from 'fs-extra' | 5 | import { readdir, readFile } from 'fs-extra' |
6 | import { CONFIG, MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers' | 6 | import { MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers' |
7 | import { join } from 'path' | 7 | import { join } from 'path' |
8 | import { getLogsValidator } from '../../../middlewares/validators/logs' | 8 | import { getLogsValidator } from '../../../middlewares/validators/logs' |
9 | import { LogLevel } from '../../../../shared/models/server/log-level.type' | 9 | import { LogLevel } from '../../../../shared/models/server/log-level.type' |
10 | import { CONFIG } from '../../../initializers/config' | ||
10 | 11 | ||
11 | const logsRouter = express.Router() | 12 | const logsRouter = express.Router() |
12 | 13 | ||
diff --git a/server/controllers/api/server/stats.ts b/server/controllers/api/server/stats.ts index 89ffd1717..951b98209 100644 --- a/server/controllers/api/server/stats.ts +++ b/server/controllers/api/server/stats.ts | |||
@@ -6,9 +6,10 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | |||
6 | import { VideoModel } from '../../../models/video/video' | 6 | import { VideoModel } from '../../../models/video/video' |
7 | import { VideoCommentModel } from '../../../models/video/video-comment' | 7 | import { VideoCommentModel } from '../../../models/video/video-comment' |
8 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' | 8 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' |
9 | import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' | 9 | import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' |
10 | import { cacheRoute } from '../../../middlewares/cache' | 10 | import { cacheRoute } from '../../../middlewares/cache' |
11 | import { VideoFileModel } from '../../../models/video/video-file' | 11 | import { VideoFileModel } from '../../../models/video/video-file' |
12 | import { CONFIG } from '../../../initializers/config' | ||
12 | 13 | ||
13 | const statsRouter = express.Router() | 14 | const statsRouter = express.Router() |
14 | 15 | ||
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index 2117bdfeb..a049e23e4 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -3,7 +3,7 @@ import * as RateLimit from 'express-rate-limit' | |||
3 | import { UserCreate, UserRight, UserRole, UserUpdate } from '../../../../shared' | 3 | import { UserCreate, UserRight, UserRole, UserUpdate } from '../../../../shared' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
5 | import { getFormattedObjects } from '../../../helpers/utils' | 5 | import { getFormattedObjects } from '../../../helpers/utils' |
6 | import { CONFIG, RATES_LIMIT, sequelizeTypescript } from '../../../initializers' | 6 | import { RATES_LIMIT, sequelizeTypescript, WEBSERVER } from '../../../initializers' |
7 | import { Emailer } from '../../../lib/emailer' | 7 | import { Emailer } from '../../../lib/emailer' |
8 | import { Redis } from '../../../lib/redis' | 8 | import { Redis } from '../../../lib/redis' |
9 | import { createUserAccountAndChannelAndPlaylist } from '../../../lib/user' | 9 | import { createUserAccountAndChannelAndPlaylist } from '../../../lib/user' |
@@ -43,6 +43,7 @@ import { myVideosHistoryRouter } from './my-history' | |||
43 | import { myNotificationsRouter } from './my-notifications' | 43 | import { myNotificationsRouter } from './my-notifications' |
44 | import { Notifier } from '../../../lib/notifier' | 44 | import { Notifier } from '../../../lib/notifier' |
45 | import { mySubscriptionsRouter } from './my-subscriptions' | 45 | import { mySubscriptionsRouter } from './my-subscriptions' |
46 | import { CONFIG } from '../../../initializers/config' | ||
46 | 47 | ||
47 | const auditLogger = auditLoggerFactory('users') | 48 | const auditLogger = auditLoggerFactory('users') |
48 | 49 | ||
@@ -293,7 +294,7 @@ async function askResetUserPassword (req: express.Request, res: express.Response | |||
293 | const user = res.locals.user | 294 | const user = res.locals.user |
294 | 295 | ||
295 | const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id) | 296 | const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id) |
296 | const url = CONFIG.WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString | 297 | const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString |
297 | await Emailer.Instance.addPasswordResetEmailJob(user.email, url) | 298 | await Emailer.Instance.addPasswordResetEmailJob(user.email, url) |
298 | 299 | ||
299 | return res.status(204).end() | 300 | return res.status(204).end() |
@@ -310,7 +311,7 @@ async function resetUserPassword (req: express.Request, res: express.Response) { | |||
310 | 311 | ||
311 | async function sendVerifyUserEmail (user: UserModel) { | 312 | async function sendVerifyUserEmail (user: UserModel) { |
312 | const verificationString = await Redis.Instance.setVerifyEmailVerificationString(user.id) | 313 | const verificationString = await Redis.Instance.setVerifyEmailVerificationString(user.id) |
313 | const url = CONFIG.WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString | 314 | const url = WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString |
314 | await Emailer.Instance.addVerifyEmailJob(user.email, url) | 315 | await Emailer.Instance.addVerifyEmailJob(user.email, url) |
315 | return | 316 | return |
316 | } | 317 | } |
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index 3533499be..1d1588eca 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import 'multer' | 2 | import 'multer' |
3 | import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' | 3 | import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' |
4 | import { getFormattedObjects } from '../../../helpers/utils' | 4 | import { getFormattedObjects } from '../../../helpers/utils' |
5 | import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers' | 5 | import { MIMETYPES, sequelizeTypescript } from '../../../initializers' |
6 | import { sendUpdateActor } from '../../../lib/activitypub/send' | 6 | import { sendUpdateActor } from '../../../lib/activitypub/send' |
7 | import { | 7 | import { |
8 | asyncMiddleware, | 8 | asyncMiddleware, |
@@ -26,6 +26,7 @@ import { updateActorAvatarFile } from '../../../lib/avatar' | |||
26 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' | 26 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' |
27 | import { VideoImportModel } from '../../../models/video/video-import' | 27 | import { VideoImportModel } from '../../../models/video/video-import' |
28 | import { AccountModel } from '../../../models/account/account' | 28 | import { AccountModel } from '../../../models/account/account' |
29 | import { CONFIG } from '../../../initializers/config' | ||
29 | 30 | ||
30 | const auditLogger = auditLoggerFactory('users-me') | 31 | const auditLogger = auditLoggerFactory('users-me') |
31 | 32 | ||
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index a173adfd0..59b906a8b 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import 'multer' | 2 | import 'multer' |
3 | import { getFormattedObjects } from '../../../helpers/utils' | 3 | import { getFormattedObjects } from '../../../helpers/utils' |
4 | import { CONFIG, sequelizeTypescript } from '../../../initializers' | 4 | import { sequelizeTypescript, WEBSERVER } from '../../../initializers' |
5 | import { | 5 | import { |
6 | asyncMiddleware, | 6 | asyncMiddleware, |
7 | asyncRetryTransactionMiddleware, | 7 | asyncRetryTransactionMiddleware, |
@@ -80,7 +80,7 @@ async function areSubscriptionsExist (req: express.Request, res: express.Respons | |||
80 | 80 | ||
81 | const handles = uris.map(u => { | 81 | const handles = uris.map(u => { |
82 | let [ name, host ] = u.split('@') | 82 | let [ name, host ] = u.split('@') |
83 | if (host === CONFIG.WEBSERVER.HOST) host = null | 83 | if (host === WEBSERVER.HOST) host = null |
84 | 84 | ||
85 | return { name, host, uri: u } | 85 | return { name, host, uri: u } |
86 | }) | 86 | }) |
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index 5881cab41..b79ce9cec 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -23,7 +23,7 @@ import { createVideoChannel } from '../../lib/video-channel' | |||
23 | import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 23 | import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
24 | import { setAsyncActorKeys } from '../../lib/activitypub' | 24 | import { setAsyncActorKeys } from '../../lib/activitypub' |
25 | import { AccountModel } from '../../models/account/account' | 25 | import { AccountModel } from '../../models/account/account' |
26 | import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers' | 26 | import { MIMETYPES, sequelizeTypescript } from '../../initializers' |
27 | import { logger } from '../../helpers/logger' | 27 | import { logger } from '../../helpers/logger' |
28 | import { VideoModel } from '../../models/video/video' | 28 | import { VideoModel } from '../../models/video/video' |
29 | import { updateAvatarValidator } from '../../middlewares/validators/avatar' | 29 | import { updateAvatarValidator } from '../../middlewares/validators/avatar' |
@@ -33,6 +33,7 @@ import { resetSequelizeInstance } from '../../helpers/database-utils' | |||
33 | import { JobQueue } from '../../lib/job-queue' | 33 | import { JobQueue } from '../../lib/job-queue' |
34 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 34 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
35 | import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' | 35 | import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' |
36 | import { CONFIG } from '../../initializers/config' | ||
36 | 37 | ||
37 | const auditLogger = auditLoggerFactory('channels') | 38 | const auditLogger = auditLoggerFactory('channels') |
38 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 39 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) |
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index feba30564..5a3d6a29d 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -12,7 +12,7 @@ import { | |||
12 | } from '../../middlewares' | 12 | } from '../../middlewares' |
13 | import { videoPlaylistsSortValidator } from '../../middlewares/validators' | 13 | import { videoPlaylistsSortValidator } from '../../middlewares/validators' |
14 | import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 14 | import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
15 | import { CONFIG, MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers' | 15 | import { MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers' |
16 | import { logger } from '../../helpers/logger' | 16 | import { logger } from '../../helpers/logger' |
17 | import { resetSequelizeInstance } from '../../helpers/database-utils' | 17 | import { resetSequelizeInstance } from '../../helpers/database-utils' |
18 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 18 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
@@ -41,6 +41,7 @@ import { copy, pathExists } from 'fs-extra' | |||
41 | import { AccountModel } from '../../models/account/account' | 41 | import { AccountModel } from '../../models/account/account' |
42 | import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' | 42 | import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' |
43 | import { JobQueue } from '../../lib/job-queue' | 43 | import { JobQueue } from '../../lib/job-queue' |
44 | import { CONFIG } from '../../initializers/config' | ||
44 | 45 | ||
45 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) | 46 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) |
46 | 47 | ||
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts index 2694577d8..7dd36e368 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/controllers/api/videos/captions.ts | |||
@@ -2,12 +2,13 @@ import * as express from 'express' | |||
2 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' | 2 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' |
3 | import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' | 3 | import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' |
4 | import { createReqFiles } from '../../../helpers/express-utils' | 4 | import { createReqFiles } from '../../../helpers/express-utils' |
5 | import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers' | 5 | import { MIMETYPES, sequelizeTypescript } from '../../../initializers' |
6 | import { getFormattedObjects } from '../../../helpers/utils' | 6 | import { getFormattedObjects } from '../../../helpers/utils' |
7 | import { VideoCaptionModel } from '../../../models/video/video-caption' | 7 | import { VideoCaptionModel } from '../../../models/video/video-caption' |
8 | import { logger } from '../../../helpers/logger' | 8 | import { logger } from '../../../helpers/logger' |
9 | import { federateVideoIfNeeded } from '../../../lib/activitypub' | 9 | import { federateVideoIfNeeded } from '../../../lib/activitypub' |
10 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | 10 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' |
11 | import { CONFIG } from '../../../initializers/config' | ||
11 | 12 | ||
12 | const reqVideoCaptionAdd = createReqFiles( | 13 | const reqVideoCaptionAdd = createReqFiles( |
13 | [ 'captionfile' ], | 14 | [ 'captionfile' ], |
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index c234a1391..5a8cd703e 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -3,7 +3,7 @@ import * as magnetUtil from 'magnet-uri' | |||
3 | import 'multer' | 3 | import 'multer' |
4 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' | 4 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' |
5 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' | 5 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' |
6 | import { CONFIG, MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers' | 6 | import { MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers' |
7 | import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' | 7 | import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' |
8 | import { createReqFiles } from '../../../helpers/express-utils' | 8 | import { createReqFiles } from '../../../helpers/express-utils' |
9 | import { logger } from '../../../helpers/logger' | 9 | import { logger } from '../../../helpers/logger' |
@@ -22,8 +22,9 @@ import { UserModel } from '../../../models/account/user' | |||
22 | import * as Bluebird from 'bluebird' | 22 | import * as Bluebird from 'bluebird' |
23 | import * as parseTorrent from 'parse-torrent' | 23 | import * as parseTorrent from 'parse-torrent' |
24 | import { getSecureTorrentName } from '../../../helpers/utils' | 24 | import { getSecureTorrentName } from '../../../helpers/utils' |
25 | import { readFile, move } from 'fs-extra' | 25 | import { move, readFile } from 'fs-extra' |
26 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' | 26 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' |
27 | import { CONFIG } from '../../../initializers/config' | ||
27 | 28 | ||
28 | const auditLogger = auditLoggerFactory('video-imports') | 29 | const auditLogger = auditLoggerFactory('video-imports') |
29 | const videoImportsRouter = express.Router() | 30 | const videoImportsRouter = express.Router() |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 393324819..9470afabf 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -8,7 +8,6 @@ import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../ | |||
8 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 8 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' |
9 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' | 9 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' |
10 | import { | 10 | import { |
11 | CONFIG, | ||
12 | MIMETYPES, | 11 | MIMETYPES, |
13 | PREVIEWS_SIZE, | 12 | PREVIEWS_SIZE, |
14 | sequelizeTypescript, | 13 | sequelizeTypescript, |
@@ -61,6 +60,7 @@ import { move } from 'fs-extra' | |||
61 | import { watchingRouter } from './watching' | 60 | import { watchingRouter } from './watching' |
62 | import { Notifier } from '../../../lib/notifier' | 61 | import { Notifier } from '../../../lib/notifier' |
63 | import { sendView } from '../../../lib/activitypub/send/send-view' | 62 | import { sendView } from '../../../lib/activitypub/send/send-view' |
63 | import { CONFIG } from '../../../initializers/config' | ||
64 | 64 | ||
65 | const auditLogger = auditLoggerFactory('videos') | 65 | const auditLogger = auditLoggerFactory('videos') |
66 | const videosRouter = express.Router() | 66 | const videosRouter = express.Router() |
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts index 2db86a2d8..58ead4799 100644 --- a/server/controllers/bots.ts +++ b/server/controllers/bots.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { asyncMiddleware } from '../middlewares' | 2 | import { asyncMiddleware } from '../middlewares' |
3 | import { CONFIG, ROUTE_CACHE_LIFETIME } from '../initializers' | 3 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers' |
4 | import * as sitemapModule from 'sitemap' | 4 | import * as sitemapModule from 'sitemap' |
5 | import { logger } from '../helpers/logger' | 5 | import { logger } from '../helpers/logger' |
6 | import { VideoModel } from '../models/video/video' | 6 | import { VideoModel } from '../models/video/video' |
@@ -35,7 +35,7 @@ async function getSitemap (req: express.Request, res: express.Response) { | |||
35 | urls = urls.concat(await getSitemapAccountUrls()) | 35 | urls = urls.concat(await getSitemapAccountUrls()) |
36 | 36 | ||
37 | const sitemap = sitemapModule.createSitemap({ | 37 | const sitemap = sitemapModule.createSitemap({ |
38 | hostname: CONFIG.WEBSERVER.URL, | 38 | hostname: WEBSERVER.URL, |
39 | urls: urls | 39 | urls: urls |
40 | }) | 40 | }) |
41 | 41 | ||
@@ -54,7 +54,7 @@ async function getSitemapVideoChannelUrls () { | |||
54 | const rows = await VideoChannelModel.listLocalsForSitemap('createdAt') | 54 | const rows = await VideoChannelModel.listLocalsForSitemap('createdAt') |
55 | 55 | ||
56 | return rows.map(channel => ({ | 56 | return rows.map(channel => ({ |
57 | url: CONFIG.WEBSERVER.URL + '/video-channels/' + channel.Actor.preferredUsername | 57 | url: WEBSERVER.URL + '/video-channels/' + channel.Actor.preferredUsername |
58 | })) | 58 | })) |
59 | } | 59 | } |
60 | 60 | ||
@@ -62,7 +62,7 @@ async function getSitemapAccountUrls () { | |||
62 | const rows = await AccountModel.listLocalsForSitemap('createdAt') | 62 | const rows = await AccountModel.listLocalsForSitemap('createdAt') |
63 | 63 | ||
64 | return rows.map(channel => ({ | 64 | return rows.map(channel => ({ |
65 | url: CONFIG.WEBSERVER.URL + '/accounts/' + channel.Actor.preferredUsername | 65 | url: WEBSERVER.URL + '/accounts/' + channel.Actor.preferredUsername |
66 | })) | 66 | })) |
67 | } | 67 | } |
68 | 68 | ||
@@ -78,14 +78,14 @@ async function getSitemapLocalVideoUrls () { | |||
78 | }) | 78 | }) |
79 | 79 | ||
80 | return resultList.data.map(v => ({ | 80 | return resultList.data.map(v => ({ |
81 | url: CONFIG.WEBSERVER.URL + '/videos/watch/' + v.uuid, | 81 | url: WEBSERVER.URL + '/videos/watch/' + v.uuid, |
82 | video: [ | 82 | video: [ |
83 | { | 83 | { |
84 | title: v.name, | 84 | title: v.name, |
85 | // Sitemap description should be < 2000 characters | 85 | // Sitemap description should be < 2000 characters |
86 | description: truncate(v.description || v.name, { length: 2000, omission: '...' }), | 86 | description: truncate(v.description || v.name, { length: 2000, omission: '...' }), |
87 | player_loc: CONFIG.WEBSERVER.URL + '/videos/embed/' + v.uuid, | 87 | player_loc: WEBSERVER.URL + '/videos/embed/' + v.uuid, |
88 | thumbnail_loc: CONFIG.WEBSERVER.URL + v.getThumbnailStaticPath() | 88 | thumbnail_loc: WEBSERVER.URL + v.getThumbnailStaticPath() |
89 | } | 89 | } |
90 | ] | 90 | ] |
91 | })) | 91 | })) |
@@ -97,5 +97,5 @@ function getSitemapBasicUrls () { | |||
97 | '/videos/local' | 97 | '/videos/local' |
98 | ] | 98 | ] |
99 | 99 | ||
100 | return paths.map(p => ({ url: CONFIG.WEBSERVER.URL + p })) | 100 | return paths.map(p => ({ url: WEBSERVER.URL + p })) |
101 | } | 101 | } |
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts index cd46b6e0f..24c41d946 100644 --- a/server/controllers/feeds.ts +++ b/server/controllers/feeds.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { CONFIG, FEEDS, ROUTE_CACHE_LIFETIME } from '../initializers/constants' | 2 | import { FEEDS, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' |
3 | import { THUMBNAILS_SIZE } from '../initializers' | 3 | import { THUMBNAILS_SIZE } from '../initializers' |
4 | import { | 4 | import { |
5 | asyncMiddleware, | 5 | asyncMiddleware, |
@@ -14,6 +14,7 @@ import * as Feed from 'pfeed' | |||
14 | import { cacheRoute } from '../middlewares/cache' | 14 | import { cacheRoute } from '../middlewares/cache' |
15 | import { VideoCommentModel } from '../models/video/video-comment' | 15 | import { VideoCommentModel } from '../models/video/video-comment' |
16 | import { buildNSFWFilter } from '../helpers/express-utils' | 16 | import { buildNSFWFilter } from '../helpers/express-utils' |
17 | import { CONFIG } from '../initializers/config' | ||
17 | 18 | ||
18 | const feedsRouter = express.Router() | 19 | const feedsRouter = express.Router() |
19 | 20 | ||
@@ -54,7 +55,7 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res | |||
54 | 55 | ||
55 | // Adding video items to the feed, one at a time | 56 | // Adding video items to the feed, one at a time |
56 | comments.forEach(comment => { | 57 | comments.forEach(comment => { |
57 | const link = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath() | 58 | const link = WEBSERVER.URL + comment.getCommentStaticPath() |
58 | 59 | ||
59 | feed.addItem({ | 60 | feed.addItem({ |
60 | title: `${comment.Video.name} - ${comment.Account.getDisplayName()}`, | 61 | title: `${comment.Video.name} - ${comment.Account.getDisplayName()}`, |
@@ -122,7 +123,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) { | |||
122 | feed.addItem({ | 123 | feed.addItem({ |
123 | title: video.name, | 124 | title: video.name, |
124 | id: video.url, | 125 | id: video.url, |
125 | link: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid, | 126 | link: WEBSERVER.URL + '/videos/watch/' + video.uuid, |
126 | description: video.getTruncatedDescription(), | 127 | description: video.getTruncatedDescription(), |
127 | content: video.description, | 128 | content: video.description, |
128 | author: [ | 129 | author: [ |
@@ -137,7 +138,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) { | |||
137 | torrent: torrents, | 138 | torrent: torrents, |
138 | thumbnail: [ | 139 | thumbnail: [ |
139 | { | 140 | { |
140 | url: CONFIG.WEBSERVER.URL + video.getThumbnailStaticPath(), | 141 | url: WEBSERVER.URL + video.getThumbnailStaticPath(), |
141 | height: THUMBNAILS_SIZE.height, | 142 | height: THUMBNAILS_SIZE.height, |
142 | width: THUMBNAILS_SIZE.width | 143 | width: THUMBNAILS_SIZE.width |
143 | } | 144 | } |
@@ -150,7 +151,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) { | |||
150 | } | 151 | } |
151 | 152 | ||
152 | function initFeed (name: string, description: string) { | 153 | function initFeed (name: string, description: string) { |
153 | const webserverUrl = CONFIG.WEBSERVER.URL | 154 | const webserverUrl = WEBSERVER.URL |
154 | 155 | ||
155 | return new Feed({ | 156 | return new Feed({ |
156 | title: name, | 157 | title: name, |
diff --git a/server/controllers/services.ts b/server/controllers/services.ts index cf7a513af..83b01b475 100644 --- a/server/controllers/services.ts +++ b/server/controllers/services.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { CONFIG, EMBED_SIZE, PREVIEWS_SIZE } from '../initializers' | 2 | import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER } from '../initializers' |
3 | import { asyncMiddleware, oembedValidator } from '../middlewares' | 3 | import { asyncMiddleware, oembedValidator } from '../middlewares' |
4 | import { accountNameWithHostGetValidator } from '../middlewares/validators' | 4 | import { accountNameWithHostGetValidator } from '../middlewares/validators' |
5 | import { VideoModel } from '../models/video/video' | 5 | import { CONFIG } from '../initializers/config' |
6 | 6 | ||
7 | const servicesRouter = express.Router() | 7 | const servicesRouter = express.Router() |
8 | 8 | ||
@@ -25,7 +25,7 @@ export { | |||
25 | 25 | ||
26 | function generateOEmbed (req: express.Request, res: express.Response) { | 26 | function generateOEmbed (req: express.Request, res: express.Response) { |
27 | const video = res.locals.video | 27 | const video = res.locals.video |
28 | const webserverUrl = CONFIG.WEBSERVER.URL | 28 | const webserverUrl = WEBSERVER.URL |
29 | const maxHeight = parseInt(req.query.maxheight, 10) | 29 | const maxHeight = parseInt(req.query.maxheight, 10) |
30 | const maxWidth = parseInt(req.query.maxwidth, 10) | 30 | const maxWidth = parseInt(req.query.maxwidth, 10) |
31 | 31 | ||
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index e65c7afd3..be5fcc8ed 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import * as cors from 'cors' | 1 | import * as cors from 'cors' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { | 3 | import { |
4 | CONFIG, | ||
5 | HLS_STREAMING_PLAYLIST_DIRECTORY, | 4 | HLS_STREAMING_PLAYLIST_DIRECTORY, |
6 | ROUTE_CACHE_LIFETIME, | 5 | ROUTE_CACHE_LIFETIME, |
7 | STATIC_DOWNLOAD_PATHS, | 6 | STATIC_DOWNLOAD_PATHS, |
8 | STATIC_MAX_AGE, | 7 | STATIC_MAX_AGE, |
9 | STATIC_PATHS | 8 | STATIC_PATHS, |
9 | WEBSERVER | ||
10 | } from '../initializers' | 10 | } from '../initializers' |
11 | import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' | 11 | import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' |
12 | import { cacheRoute } from '../middlewares/cache' | 12 | import { cacheRoute } from '../middlewares/cache' |
@@ -17,6 +17,7 @@ import { VideoCommentModel } from '../models/video/video-comment' | |||
17 | import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo' | 17 | import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo' |
18 | import { join } from 'path' | 18 | import { join } from 'path' |
19 | import { root } from '../helpers/core-utils' | 19 | import { root } from '../helpers/core-utils' |
20 | import { CONFIG } from '../initializers/config' | ||
20 | 21 | ||
21 | const packageJSON = require('../../../package.json') | 22 | const packageJSON = require('../../../package.json') |
22 | const staticRouter = express.Router() | 23 | const staticRouter = express.Router() |
@@ -121,7 +122,7 @@ staticRouter.use('/.well-known/nodeinfo', | |||
121 | links: [ | 122 | links: [ |
122 | { | 123 | { |
123 | rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', | 124 | rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', |
124 | href: CONFIG.WEBSERVER.URL + '/nodeinfo/2.0.json' | 125 | href: WEBSERVER.URL + '/nodeinfo/2.0.json' |
125 | } | 126 | } |
126 | ] | 127 | ] |
127 | }) | 128 | }) |
diff --git a/server/controllers/tracker.ts b/server/controllers/tracker.ts index 56a3424a3..912f82b86 100644 --- a/server/controllers/tracker.ts +++ b/server/controllers/tracker.ts | |||
@@ -4,10 +4,11 @@ import * as http from 'http' | |||
4 | import * as bitTorrentTracker from 'bittorrent-tracker' | 4 | import * as bitTorrentTracker from 'bittorrent-tracker' |
5 | import * as proxyAddr from 'proxy-addr' | 5 | import * as proxyAddr from 'proxy-addr' |
6 | import { Server as WebSocketServer } from 'ws' | 6 | import { Server as WebSocketServer } from 'ws' |
7 | import { CONFIG, TRACKER_RATE_LIMITS } from '../initializers/constants' | 7 | import { TRACKER_RATE_LIMITS } from '../initializers/constants' |
8 | import { VideoFileModel } from '../models/video/video-file' | 8 | import { VideoFileModel } from '../models/video/video-file' |
9 | import { parse } from 'url' | 9 | import { parse } from 'url' |
10 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' | 10 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' |
11 | import { CONFIG } from '../initializers/config' | ||
11 | 12 | ||
12 | const TrackerServer = bitTorrentTracker.Server | 13 | const TrackerServer = bitTorrentTracker.Server |
13 | 14 | ||
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts index af37bce16..f536da439 100644 --- a/server/helpers/audit-logger.ts +++ b/server/helpers/audit-logger.ts | |||
@@ -4,11 +4,11 @@ import { diff } from 'deep-object-diff' | |||
4 | import { chain } from 'lodash' | 4 | import { chain } from 'lodash' |
5 | import * as flatten from 'flat' | 5 | import * as flatten from 'flat' |
6 | import * as winston from 'winston' | 6 | import * as winston from 'winston' |
7 | import { CONFIG } from '../initializers' | ||
8 | import { jsonLoggerFormat, labelFormatter } from './logger' | 7 | import { jsonLoggerFormat, labelFormatter } from './logger' |
9 | import { User, VideoAbuse, VideoChannel, VideoDetails, VideoImport } from '../../shared' | 8 | import { User, VideoAbuse, VideoChannel, VideoDetails, VideoImport } from '../../shared' |
10 | import { VideoComment } from '../../shared/models/videos/video-comment.model' | 9 | import { VideoComment } from '../../shared/models/videos/video-comment.model' |
11 | import { CustomConfig } from '../../shared/models/server/custom-config.model' | 10 | import { CustomConfig } from '../../shared/models/server/custom-config.model' |
11 | import { CONFIG } from '../initializers/config' | ||
12 | 12 | ||
13 | function getAuditIdFromRes (res: express.Response) { | 13 | function getAuditIdFromRes (res: express.Response) { |
14 | return res.locals.oauth.token.User.username | 14 | return res.locals.oauth.token.User.username |
diff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.ts index 0fb11a125..7174d4654 100644 --- a/server/helpers/captions-utils.ts +++ b/server/helpers/captions-utils.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { CONFIG } from '../initializers' | 2 | import { CONFIG } from '../initializers/config' |
3 | import { VideoCaptionModel } from '../models/video/video-caption' | 3 | import { VideoCaptionModel } from '../models/video/video-caption' |
4 | import * as srt2vtt from 'srt-to-vtt' | 4 | import * as srt2vtt from 'srt-to-vtt' |
5 | import { createReadStream, createWriteStream, remove, move } from 'fs-extra' | 5 | import { createReadStream, createWriteStream, remove, move } from 'fs-extra' |
diff --git a/server/helpers/custom-validators/video-channels.ts b/server/helpers/custom-validators/video-channels.ts index fad7a9bcf..ca8d207cf 100644 --- a/server/helpers/custom-validators/video-channels.ts +++ b/server/helpers/custom-validators/video-channels.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import 'express-validator' | 2 | import 'express-validator' |
3 | import 'multer' | 3 | import 'multer' |
4 | import * as validator from 'validator' | 4 | import * as validator from 'validator' |
5 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' | 5 | import { CONSTRAINTS_FIELDS } from '../../initializers' |
6 | import { VideoChannelModel } from '../../models/video/video-channel' | 6 | import { VideoChannelModel } from '../../models/video/video-channel' |
7 | import { exists } from './misc' | 7 | import { exists } from './misc' |
8 | 8 | ||
diff --git a/server/helpers/custom-validators/webfinger.ts b/server/helpers/custom-validators/webfinger.ts index 80a7e4a9d..b18e43fad 100644 --- a/server/helpers/custom-validators/webfinger.ts +++ b/server/helpers/custom-validators/webfinger.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { CONFIG, REMOTE_SCHEME } from '../../initializers' | 1 | import { REMOTE_SCHEME, WEBSERVER } from '../../initializers' |
2 | import { sanitizeHost } from '../core-utils' | 2 | import { sanitizeHost } from '../core-utils' |
3 | import { exists } from './misc' | 3 | import { exists } from './misc' |
4 | 4 | ||
@@ -11,7 +11,7 @@ function isWebfingerLocalResourceValid (value: string) { | |||
11 | if (actorParts.length !== 2) return false | 11 | if (actorParts.length !== 2) return false |
12 | 12 | ||
13 | const host = actorParts[1] | 13 | const host = actorParts[1] |
14 | return sanitizeHost(host, REMOTE_SCHEME.HTTP) === CONFIG.WEBSERVER.HOST | 14 | return sanitizeHost(host, REMOTE_SCHEME.HTTP) === WEBSERVER.HOST |
15 | } | 15 | } |
16 | 16 | ||
17 | // --------------------------------------------------------------------------- | 17 | // --------------------------------------------------------------------------- |
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts index fef2da313..2b574ab8e 100644 --- a/server/helpers/express-utils.ts +++ b/server/helpers/express-utils.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as multer from 'multer' | 2 | import * as multer from 'multer' |
3 | import { CONFIG, REMOTE_SCHEME } from '../initializers' | 3 | import { REMOTE_SCHEME } from '../initializers' |
4 | import { logger } from './logger' | 4 | import { logger } from './logger' |
5 | import { deleteFileAsync, generateRandomString } from './utils' | 5 | import { deleteFileAsync, generateRandomString } from './utils' |
6 | import { extname } from 'path' | 6 | import { extname } from 'path' |
7 | import { isArray } from './custom-validators/misc' | 7 | import { isArray } from './custom-validators/misc' |
8 | import { CONFIG } from '../initializers/config' | ||
8 | 9 | ||
9 | function buildNSFWFilter (res?: express.Response, paramNSFW?: string) { | 10 | function buildNSFWFilter (res?: express.Response, paramNSFW?: string) { |
10 | if (paramNSFW === 'true') return true | 11 | if (paramNSFW === 'true') return true |
@@ -58,7 +59,7 @@ function getHostWithPort (host: string) { | |||
58 | return host | 59 | return host |
59 | } | 60 | } |
60 | 61 | ||
61 | function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { | 62 | function badRequest (req: express.Request, res: express.Response) { |
62 | return res.type('json').status(400).end() | 63 | return res.type('json').status(400).end() |
63 | } | 64 | } |
64 | 65 | ||
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index c477e2e89..d818c459c 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import * as ffmpeg from 'fluent-ffmpeg' | 1 | import * as ffmpeg from 'fluent-ffmpeg' |
2 | import { dirname, join } from 'path' | 2 | import { dirname, join } from 'path' |
3 | import { getTargetBitrate, VideoResolution } from '../../shared/models/videos' | 3 | import { getTargetBitrate, VideoResolution } from '../../shared/models/videos' |
4 | import { CONFIG, FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants' | 4 | import { FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants' |
5 | import { processImage } from './image-utils' | 5 | import { processImage } from './image-utils' |
6 | import { logger } from './logger' | 6 | import { logger } from './logger' |
7 | import { checkFFmpegEncoders } from '../initializers/checker-before-init' | 7 | import { checkFFmpegEncoders } from '../initializers/checker-before-init' |
8 | import { remove, readFile, writeFile } from 'fs-extra' | 8 | import { readFile, remove, writeFile } from 'fs-extra' |
9 | import { CONFIG } from '../initializers/config' | ||
9 | 10 | ||
10 | function computeResolutionsToTranscode (videoFileHeight: number) { | 11 | function computeResolutionsToTranscode (videoFileHeight: number) { |
11 | const resolutionsEnabled: number[] = [] | 12 | const resolutionsEnabled: number[] = [] |
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index f8a142718..734523b01 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | import { mkdirpSync } from 'fs-extra' | 2 | import { mkdirpSync } from 'fs-extra' |
3 | import * as path from 'path' | 3 | import * as path from 'path' |
4 | import * as winston from 'winston' | 4 | import * as winston from 'winston' |
5 | import { CONFIG } from '../initializers' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { omit } from 'lodash' | 6 | import { omit } from 'lodash' |
7 | 7 | ||
8 | const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | 8 | const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT |
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 3762e4d3c..02854b164 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { createWriteStream, remove } from 'fs-extra' | 2 | import { createWriteStream, remove } from 'fs-extra' |
3 | import * as request from 'request' | 3 | import * as request from 'request' |
4 | import { ACTIVITY_PUB, CONFIG } from '../initializers' | 4 | import { ACTIVITY_PUB } from '../initializers' |
5 | import { processImage } from './image-utils' | 5 | import { processImage } from './image-utils' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { logger } from './logger' | 7 | import { logger } from './logger' |
8 | import { CONFIG } from '../initializers/config' | ||
8 | 9 | ||
9 | function doRequest <T> ( | 10 | function doRequest <T> ( |
10 | requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean }, | 11 | requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean }, |
diff --git a/server/helpers/signup.ts b/server/helpers/signup.ts index cdce7989d..5eb56b3cf 100644 --- a/server/helpers/signup.ts +++ b/server/helpers/signup.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { CONFIG } from '../initializers' | ||
2 | import { UserModel } from '../models/account/user' | 1 | import { UserModel } from '../models/account/user' |
3 | import * as ipaddr from 'ipaddr.js' | 2 | import * as ipaddr from 'ipaddr.js' |
3 | import { CONFIG } from '../initializers/config' | ||
4 | |||
4 | const isCidr = require('is-cidr') | 5 | const isCidr = require('is-cidr') |
5 | 6 | ||
6 | async function isSignupAllowed () { | 7 | async function isSignupAllowed () { |
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index cb0e823c5..94ceb15e0 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import { ResultList } from '../../shared' | 1 | import { ResultList } from '../../shared' |
2 | import { CONFIG } from '../initializers' | ||
3 | import { ApplicationModel } from '../models/application/application' | 2 | import { ApplicationModel } from '../models/application/application' |
4 | import { execPromise, execPromise2, pseudoRandomBytesPromise, sha256 } from './core-utils' | 3 | import { execPromise, execPromise2, pseudoRandomBytesPromise, sha256 } from './core-utils' |
5 | import { logger } from './logger' | 4 | import { logger } from './logger' |
@@ -7,6 +6,7 @@ import { join } from 'path' | |||
7 | import { Instance as ParseTorrent } from 'parse-torrent' | 6 | import { Instance as ParseTorrent } from 'parse-torrent' |
8 | import { remove } from 'fs-extra' | 7 | import { remove } from 'fs-extra' |
9 | import * as memoizee from 'memoizee' | 8 | import * as memoizee from 'memoizee' |
9 | import { CONFIG } from '../initializers/config' | ||
10 | 10 | ||
11 | function deleteFileAsync (path: string) { | 11 | function deleteFileAsync (path: string) { |
12 | remove(path) | 12 | remove(path) |
diff --git a/server/helpers/webfinger.ts b/server/helpers/webfinger.ts index 156376943..049808846 100644 --- a/server/helpers/webfinger.ts +++ b/server/helpers/webfinger.ts | |||
@@ -3,7 +3,7 @@ import { WebFingerData } from '../../shared' | |||
3 | import { ActorModel } from '../models/activitypub/actor' | 3 | import { ActorModel } from '../models/activitypub/actor' |
4 | import { isTestInstance } from './core-utils' | 4 | import { isTestInstance } from './core-utils' |
5 | import { isActivityPubUrlValid } from './custom-validators/activitypub/misc' | 5 | import { isActivityPubUrlValid } from './custom-validators/activitypub/misc' |
6 | import { CONFIG } from '../initializers' | 6 | import { WEBSERVER } from '../initializers/constants' |
7 | 7 | ||
8 | const webfinger = new WebFinger({ | 8 | const webfinger = new WebFinger({ |
9 | webfist_fallback: false, | 9 | webfist_fallback: false, |
@@ -19,7 +19,7 @@ async function loadActorUrlOrGetFromWebfinger (uriArg: string) { | |||
19 | const [ name, host ] = uri.split('@') | 19 | const [ name, host ] = uri.split('@') |
20 | let actor: ActorModel | 20 | let actor: ActorModel |
21 | 21 | ||
22 | if (host === CONFIG.WEBSERVER.HOST) { | 22 | if (host === WEBSERVER.HOST) { |
23 | actor = await ActorModel.loadLocalByName(name) | 23 | actor = await ActorModel.loadLocalByName(name) |
24 | } else { | 24 | } else { |
25 | actor = await ActorModel.loadByNameAndHost(name, host) | 25 | actor = await ActorModel.loadByNameAndHost(name, host) |
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 3c9a0b96a..14dfe0d28 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts | |||
@@ -2,7 +2,7 @@ import { logger } from './logger' | |||
2 | import { generateVideoImportTmpPath } from './utils' | 2 | import { generateVideoImportTmpPath } from './utils' |
3 | import * as WebTorrent from 'webtorrent' | 3 | import * as WebTorrent from 'webtorrent' |
4 | import { createWriteStream, ensureDir, remove } from 'fs-extra' | 4 | import { createWriteStream, ensureDir, remove } from 'fs-extra' |
5 | import { CONFIG } from '../initializers' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { dirname, join } from 'path' | 6 | import { dirname, join } from 'path' |
7 | 7 | ||
8 | async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) { | 8 | async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) { |
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index 85f752284..db3115085 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts | |||
@@ -4,19 +4,20 @@ import { UserModel } from '../models/account/user' | |||
4 | import { ApplicationModel } from '../models/application/application' | 4 | import { ApplicationModel } from '../models/application/application' |
5 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 5 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
6 | import { parse } from 'url' | 6 | import { parse } from 'url' |
7 | import { CONFIG } from './constants' | 7 | import { CONFIG } from './config' |
8 | import { logger } from '../helpers/logger' | 8 | import { logger } from '../helpers/logger' |
9 | import { getServerActor } from '../helpers/utils' | 9 | import { getServerActor } from '../helpers/utils' |
10 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' | 10 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' |
11 | import { isArray } from '../helpers/custom-validators/misc' | 11 | import { isArray } from '../helpers/custom-validators/misc' |
12 | import { uniq } from 'lodash' | 12 | import { uniq } from 'lodash' |
13 | import { Emailer } from '../lib/emailer' | 13 | import { Emailer } from '../lib/emailer' |
14 | import { WEBSERVER } from './constants' | ||
14 | 15 | ||
15 | async function checkActivityPubUrls () { | 16 | async function checkActivityPubUrls () { |
16 | const actor = await getServerActor() | 17 | const actor = await getServerActor() |
17 | 18 | ||
18 | const parsed = parse(actor.url) | 19 | const parsed = parse(actor.url) |
19 | if (CONFIG.WEBSERVER.HOST !== parsed.host) { | 20 | if (WEBSERVER.HOST !== parsed.host) { |
20 | const NODE_ENV = config.util.getEnv('NODE_ENV') | 21 | const NODE_ENV = config.util.getEnv('NODE_ENV') |
21 | const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR') | 22 | const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR') |
22 | 23 | ||
diff --git a/server/initializers/config.ts b/server/initializers/config.ts new file mode 100644 index 000000000..8dd62cba8 --- /dev/null +++ b/server/initializers/config.ts | |||
@@ -0,0 +1,255 @@ | |||
1 | import { IConfig } from 'config' | ||
2 | import { dirname, join } from 'path' | ||
3 | import { VideosRedundancy } from '../../shared/models' | ||
4 | // Do not use barrels, remain constants as independent as possible | ||
5 | import { buildPath, parseBytes, parseDuration, root } from '../helpers/core-utils' | ||
6 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | ||
7 | import * as bytes from 'bytes' | ||
8 | |||
9 | // Use a variable to reload the configuration if we need | ||
10 | let config: IConfig = require('config') | ||
11 | |||
12 | const configChangedHandlers: Function[] = [] | ||
13 | |||
14 | const CONFIG = { | ||
15 | CUSTOM_FILE: getLocalConfigFilePath(), | ||
16 | LISTEN: { | ||
17 | PORT: config.get<number>('listen.port'), | ||
18 | HOSTNAME: config.get<string>('listen.hostname') | ||
19 | }, | ||
20 | DATABASE: { | ||
21 | DBNAME: 'peertube' + config.get<string>('database.suffix'), | ||
22 | HOSTNAME: config.get<string>('database.hostname'), | ||
23 | PORT: config.get<number>('database.port'), | ||
24 | USERNAME: config.get<string>('database.username'), | ||
25 | PASSWORD: config.get<string>('database.password'), | ||
26 | POOL: { | ||
27 | MAX: config.get<number>('database.pool.max') | ||
28 | } | ||
29 | }, | ||
30 | REDIS: { | ||
31 | HOSTNAME: config.has('redis.hostname') ? config.get<string>('redis.hostname') : null, | ||
32 | PORT: config.has('redis.port') ? config.get<number>('redis.port') : null, | ||
33 | SOCKET: config.has('redis.socket') ? config.get<string>('redis.socket') : null, | ||
34 | AUTH: config.has('redis.auth') ? config.get<string>('redis.auth') : null, | ||
35 | DB: config.has('redis.db') ? config.get<number>('redis.db') : null | ||
36 | }, | ||
37 | SMTP: { | ||
38 | HOSTNAME: config.get<string>('smtp.hostname'), | ||
39 | PORT: config.get<number>('smtp.port'), | ||
40 | USERNAME: config.get<string>('smtp.username'), | ||
41 | PASSWORD: config.get<string>('smtp.password'), | ||
42 | TLS: config.get<boolean>('smtp.tls'), | ||
43 | DISABLE_STARTTLS: config.get<boolean>('smtp.disable_starttls'), | ||
44 | CA_FILE: config.get<string>('smtp.ca_file'), | ||
45 | FROM_ADDRESS: config.get<string>('smtp.from_address') | ||
46 | }, | ||
47 | STORAGE: { | ||
48 | TMP_DIR: buildPath(config.get<string>('storage.tmp')), | ||
49 | AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), | ||
50 | LOG_DIR: buildPath(config.get<string>('storage.logs')), | ||
51 | VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), | ||
52 | STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')), | ||
53 | REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')), | ||
54 | THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')), | ||
55 | PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')), | ||
56 | CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')), | ||
57 | TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')), | ||
58 | CACHE_DIR: buildPath(config.get<string>('storage.cache')) | ||
59 | }, | ||
60 | WEBSERVER: { | ||
61 | SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http', | ||
62 | WS: config.get<boolean>('webserver.https') === true ? 'wss' : 'ws', | ||
63 | HOSTNAME: config.get<string>('webserver.hostname'), | ||
64 | PORT: config.get<number>('webserver.port') | ||
65 | }, | ||
66 | TRUST_PROXY: config.get<string[]>('trust_proxy'), | ||
67 | LOG: { | ||
68 | LEVEL: config.get<string>('log.level') | ||
69 | }, | ||
70 | SEARCH: { | ||
71 | REMOTE_URI: { | ||
72 | USERS: config.get<boolean>('search.remote_uri.users'), | ||
73 | ANONYMOUS: config.get<boolean>('search.remote_uri.anonymous') | ||
74 | } | ||
75 | }, | ||
76 | TRENDING: { | ||
77 | VIDEOS: { | ||
78 | INTERVAL_DAYS: config.get<number>('trending.videos.interval_days') | ||
79 | } | ||
80 | }, | ||
81 | REDUNDANCY: { | ||
82 | VIDEOS: { | ||
83 | CHECK_INTERVAL: parseDuration(config.get<string>('redundancy.videos.check_interval')), | ||
84 | STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies')) | ||
85 | } | ||
86 | }, | ||
87 | CSP: { | ||
88 | ENABLED: config.get<boolean>('csp.enabled'), | ||
89 | REPORT_ONLY: config.get<boolean>('csp.report_only'), | ||
90 | REPORT_URI: config.get<boolean>('csp.report_uri') | ||
91 | }, | ||
92 | TRACKER: { | ||
93 | ENABLED: config.get<boolean>('tracker.enabled'), | ||
94 | PRIVATE: config.get<boolean>('tracker.private'), | ||
95 | REJECT_TOO_MANY_ANNOUNCES: config.get<boolean>('tracker.reject_too_many_announces') | ||
96 | }, | ||
97 | ADMIN: { | ||
98 | get EMAIL () { return config.get<string>('admin.email') } | ||
99 | }, | ||
100 | CONTACT_FORM: { | ||
101 | get ENABLED () { return config.get<boolean>('contact_form.enabled') } | ||
102 | }, | ||
103 | SIGNUP: { | ||
104 | get ENABLED () { return config.get<boolean>('signup.enabled') }, | ||
105 | get LIMIT () { return config.get<number>('signup.limit') }, | ||
106 | get REQUIRES_EMAIL_VERIFICATION () { return config.get<boolean>('signup.requires_email_verification') }, | ||
107 | FILTERS: { | ||
108 | CIDR: { | ||
109 | get WHITELIST () { return config.get<string[]>('signup.filters.cidr.whitelist') }, | ||
110 | get BLACKLIST () { return config.get<string[]>('signup.filters.cidr.blacklist') } | ||
111 | } | ||
112 | } | ||
113 | }, | ||
114 | USER: { | ||
115 | get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) }, | ||
116 | get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) } | ||
117 | }, | ||
118 | TRANSCODING: { | ||
119 | get ENABLED () { return config.get<boolean>('transcoding.enabled') }, | ||
120 | get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') }, | ||
121 | get THREADS () { return config.get<number>('transcoding.threads') }, | ||
122 | RESOLUTIONS: { | ||
123 | get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') }, | ||
124 | get '360p' () { return config.get<boolean>('transcoding.resolutions.360p') }, | ||
125 | get '480p' () { return config.get<boolean>('transcoding.resolutions.480p') }, | ||
126 | get '720p' () { return config.get<boolean>('transcoding.resolutions.720p') }, | ||
127 | get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') } | ||
128 | }, | ||
129 | HLS: { | ||
130 | get ENABLED () { return config.get<boolean>('transcoding.hls.enabled') } | ||
131 | } | ||
132 | }, | ||
133 | IMPORT: { | ||
134 | VIDEOS: { | ||
135 | HTTP: { | ||
136 | get ENABLED () { return config.get<boolean>('import.videos.http.enabled') } | ||
137 | }, | ||
138 | TORRENT: { | ||
139 | get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') } | ||
140 | } | ||
141 | } | ||
142 | }, | ||
143 | AUTO_BLACKLIST: { | ||
144 | VIDEOS: { | ||
145 | OF_USERS: { | ||
146 | get ENABLED () { return config.get<boolean>('auto_blacklist.videos.of_users.enabled') } | ||
147 | } | ||
148 | } | ||
149 | }, | ||
150 | CACHE: { | ||
151 | PREVIEWS: { | ||
152 | get SIZE () { return config.get<number>('cache.previews.size') } | ||
153 | }, | ||
154 | VIDEO_CAPTIONS: { | ||
155 | get SIZE () { return config.get<number>('cache.captions.size') } | ||
156 | } | ||
157 | }, | ||
158 | INSTANCE: { | ||
159 | get NAME () { return config.get<string>('instance.name') }, | ||
160 | get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') }, | ||
161 | get DESCRIPTION () { return config.get<string>('instance.description') }, | ||
162 | get TERMS () { return config.get<string>('instance.terms') }, | ||
163 | get IS_NSFW () { return config.get<boolean>('instance.is_nsfw') }, | ||
164 | get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') }, | ||
165 | get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') }, | ||
166 | CUSTOMIZATIONS: { | ||
167 | get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') }, | ||
168 | get CSS () { return config.get<string>('instance.customizations.css') } | ||
169 | }, | ||
170 | get ROBOTS () { return config.get<string>('instance.robots') }, | ||
171 | get SECURITYTXT () { return config.get<string>('instance.securitytxt') }, | ||
172 | get SECURITYTXT_CONTACT () { return config.get<string>('admin.email') } | ||
173 | }, | ||
174 | SERVICES: { | ||
175 | TWITTER: { | ||
176 | get USERNAME () { return config.get<string>('services.twitter.username') }, | ||
177 | get WHITELISTED () { return config.get<boolean>('services.twitter.whitelisted') } | ||
178 | } | ||
179 | }, | ||
180 | FOLLOWERS: { | ||
181 | INSTANCE: { | ||
182 | get ENABLED () { return config.get<boolean>('followers.instance.enabled') }, | ||
183 | get MANUAL_APPROVAL () { return config.get<boolean>('followers.instance.manual_approval') } | ||
184 | } | ||
185 | } | ||
186 | } | ||
187 | |||
188 | function registerConfigChangedHandler (fun: Function) { | ||
189 | configChangedHandlers.push(fun) | ||
190 | } | ||
191 | |||
192 | // --------------------------------------------------------------------------- | ||
193 | |||
194 | export { | ||
195 | CONFIG, | ||
196 | registerConfigChangedHandler | ||
197 | } | ||
198 | |||
199 | // --------------------------------------------------------------------------- | ||
200 | |||
201 | function getLocalConfigFilePath () { | ||
202 | const configSources = config.util.getConfigSources() | ||
203 | if (configSources.length === 0) throw new Error('Invalid config source.') | ||
204 | |||
205 | let filename = 'local' | ||
206 | if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}` | ||
207 | if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}` | ||
208 | |||
209 | return join(dirname(configSources[ 0 ].name), filename + '.json') | ||
210 | } | ||
211 | |||
212 | function buildVideosRedundancy (objs: any[]): VideosRedundancy[] { | ||
213 | if (!objs) return [] | ||
214 | |||
215 | if (!Array.isArray(objs)) return objs | ||
216 | |||
217 | return objs.map(obj => { | ||
218 | return Object.assign({}, obj, { | ||
219 | minLifetime: parseDuration(obj.min_lifetime), | ||
220 | size: bytes.parse(obj.size), | ||
221 | minViews: obj.min_views | ||
222 | }) | ||
223 | }) | ||
224 | } | ||
225 | |||
226 | export function reloadConfig () { | ||
227 | |||
228 | function directory () { | ||
229 | if (process.env.NODE_CONFIG_DIR) { | ||
230 | return process.env.NODE_CONFIG_DIR | ||
231 | } | ||
232 | |||
233 | return join(root(), 'config') | ||
234 | } | ||
235 | |||
236 | function purge () { | ||
237 | for (const fileName in require.cache) { | ||
238 | if (-1 === fileName.indexOf(directory())) { | ||
239 | continue | ||
240 | } | ||
241 | |||
242 | delete require.cache[fileName] | ||
243 | } | ||
244 | |||
245 | delete require.cache[require.resolve('config')] | ||
246 | } | ||
247 | |||
248 | purge() | ||
249 | |||
250 | config = require('config') | ||
251 | |||
252 | for (const configChangedHandler of configChangedHandlers) { | ||
253 | configChangedHandler() | ||
254 | } | ||
255 | } | ||
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 739ea5502..3922d8515 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -1,20 +1,16 @@ | |||
1 | import { IConfig } from 'config' | 1 | import { join } from 'path' |
2 | import { dirname, join } from 'path' | 2 | import { JobType, VideoRateType, VideoState } from '../../shared/models' |
3 | import { JobType, VideoRateType, VideoState, VideosRedundancy } from '../../shared/models' | ||
4 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 3 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
5 | import { FollowState } from '../../shared/models/actors' | 4 | import { FollowState } from '../../shared/models/actors' |
6 | import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos' | 5 | import { VideoAbuseState, VideoImportState, VideoPrivacy, VideoTranscodingFPS } from '../../shared/models/videos' |
7 | // Do not use barrels, remain constants as independent as possible | 6 | // Do not use barrels, remain constants as independent as possible |
8 | import { buildPath, isTestInstance, parseDuration, parseBytes, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' | 7 | import { isTestInstance, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' |
9 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | 8 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' |
10 | import { invert } from 'lodash' | 9 | import { invert } from 'lodash' |
11 | import { CronRepeatOptions, EveryRepeatOptions } from 'bull' | 10 | import { CronRepeatOptions, EveryRepeatOptions } from 'bull' |
12 | import * as bytes from 'bytes' | ||
13 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' | 11 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' |
14 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' | 12 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' |
15 | 13 | import { CONFIG, registerConfigChangedHandler } from './config' | |
16 | // Use a variable to reload the configuration if we need | ||
17 | let config: IConfig = require('config') | ||
18 | 14 | ||
19 | // --------------------------------------------------------------------------- | 15 | // --------------------------------------------------------------------------- |
20 | 16 | ||
@@ -32,6 +28,15 @@ const PAGINATION = { | |||
32 | } | 28 | } |
33 | } | 29 | } |
34 | 30 | ||
31 | const WEBSERVER = { | ||
32 | URL: '', | ||
33 | HOST: '', | ||
34 | SCHEME: '', | ||
35 | WS: '', | ||
36 | HOSTNAME: '', | ||
37 | PORT: 0 | ||
38 | } | ||
39 | |||
35 | // Sortable columns per schema | 40 | // Sortable columns per schema |
36 | const SORTABLE_COLUMNS = { | 41 | const SORTABLE_COLUMNS = { |
37 | USERS: [ 'id', 'username', 'createdAt' ], | 42 | USERS: [ 'id', 'username', 'createdAt' ], |
@@ -102,7 +107,7 @@ const REMOTE_SCHEME = { | |||
102 | } | 107 | } |
103 | 108 | ||
104 | // TODO: remove 'video-file' | 109 | // TODO: remove 'video-file' |
105 | const JOB_ATTEMPTS: { [ id in (JobType | 'video-file') ]: number } = { | 110 | const JOB_ATTEMPTS: { [id in (JobType | 'video-file')]: number } = { |
106 | 'activitypub-http-broadcast': 5, | 111 | 'activitypub-http-broadcast': 5, |
107 | 'activitypub-http-unicast': 5, | 112 | 'activitypub-http-unicast': 5, |
108 | 'activitypub-http-fetcher': 5, | 113 | 'activitypub-http-fetcher': 5, |
@@ -115,7 +120,7 @@ const JOB_ATTEMPTS: { [ id in (JobType | 'video-file') ]: number } = { | |||
115 | 'videos-views': 1, | 120 | 'videos-views': 1, |
116 | 'activitypub-refresher': 1 | 121 | 'activitypub-refresher': 1 |
117 | } | 122 | } |
118 | const JOB_CONCURRENCY: { [ id in (JobType | 'video-file') ]: number } = { | 123 | const JOB_CONCURRENCY: { [id in (JobType | 'video-file')]: number } = { |
119 | 'activitypub-http-broadcast': 1, | 124 | 'activitypub-http-broadcast': 1, |
120 | 'activitypub-http-unicast': 5, | 125 | 'activitypub-http-unicast': 5, |
121 | 'activitypub-http-fetcher': 1, | 126 | 'activitypub-http-fetcher': 1, |
@@ -128,7 +133,7 @@ const JOB_CONCURRENCY: { [ id in (JobType | 'video-file') ]: number } = { | |||
128 | 'videos-views': 1, | 133 | 'videos-views': 1, |
129 | 'activitypub-refresher': 1 | 134 | 'activitypub-refresher': 1 |
130 | } | 135 | } |
131 | const JOB_TTL: { [ id in (JobType | 'video-file') ]: number } = { | 136 | const JOB_TTL: { [id in (JobType | 'video-file')]: number } = { |
132 | 'activitypub-http-broadcast': 60000 * 10, // 10 minutes | 137 | 'activitypub-http-broadcast': 60000 * 10, // 10 minutes |
133 | 'activitypub-http-unicast': 60000 * 10, // 10 minutes | 138 | 'activitypub-http-unicast': 60000 * 10, // 10 minutes |
134 | 'activitypub-http-fetcher': 60000 * 10, // 10 minutes | 139 | 'activitypub-http-fetcher': 60000 * 10, // 10 minutes |
@@ -163,184 +168,6 @@ let SCHEDULER_INTERVALS_MS = { | |||
163 | 168 | ||
164 | // --------------------------------------------------------------------------- | 169 | // --------------------------------------------------------------------------- |
165 | 170 | ||
166 | const CONFIG = { | ||
167 | CUSTOM_FILE: getLocalConfigFilePath(), | ||
168 | LISTEN: { | ||
169 | PORT: config.get<number>('listen.port'), | ||
170 | HOSTNAME: config.get<string>('listen.hostname') | ||
171 | }, | ||
172 | DATABASE: { | ||
173 | DBNAME: 'peertube' + config.get<string>('database.suffix'), | ||
174 | HOSTNAME: config.get<string>('database.hostname'), | ||
175 | PORT: config.get<number>('database.port'), | ||
176 | USERNAME: config.get<string>('database.username'), | ||
177 | PASSWORD: config.get<string>('database.password'), | ||
178 | POOL: { | ||
179 | MAX: config.get<number>('database.pool.max') | ||
180 | } | ||
181 | }, | ||
182 | REDIS: { | ||
183 | HOSTNAME: config.has('redis.hostname') ? config.get<string>('redis.hostname') : null, | ||
184 | PORT: config.has('redis.port') ? config.get<number>('redis.port') : null, | ||
185 | SOCKET: config.has('redis.socket') ? config.get<string>('redis.socket') : null, | ||
186 | AUTH: config.has('redis.auth') ? config.get<string>('redis.auth') : null, | ||
187 | DB: config.has('redis.db') ? config.get<number>('redis.db') : null | ||
188 | }, | ||
189 | SMTP: { | ||
190 | HOSTNAME: config.get<string>('smtp.hostname'), | ||
191 | PORT: config.get<number>('smtp.port'), | ||
192 | USERNAME: config.get<string>('smtp.username'), | ||
193 | PASSWORD: config.get<string>('smtp.password'), | ||
194 | TLS: config.get<boolean>('smtp.tls'), | ||
195 | DISABLE_STARTTLS: config.get<boolean>('smtp.disable_starttls'), | ||
196 | CA_FILE: config.get<string>('smtp.ca_file'), | ||
197 | FROM_ADDRESS: config.get<string>('smtp.from_address') | ||
198 | }, | ||
199 | STORAGE: { | ||
200 | TMP_DIR: buildPath(config.get<string>('storage.tmp')), | ||
201 | AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), | ||
202 | LOG_DIR: buildPath(config.get<string>('storage.logs')), | ||
203 | VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), | ||
204 | STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')), | ||
205 | REDUNDANCY_DIR: buildPath(config.get<string>('storage.redundancy')), | ||
206 | THUMBNAILS_DIR: buildPath(config.get<string>('storage.thumbnails')), | ||
207 | PREVIEWS_DIR: buildPath(config.get<string>('storage.previews')), | ||
208 | CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')), | ||
209 | TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')), | ||
210 | CACHE_DIR: buildPath(config.get<string>('storage.cache')) | ||
211 | }, | ||
212 | WEBSERVER: { | ||
213 | SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http', | ||
214 | WS: config.get<boolean>('webserver.https') === true ? 'wss' : 'ws', | ||
215 | HOSTNAME: config.get<string>('webserver.hostname'), | ||
216 | PORT: config.get<number>('webserver.port'), | ||
217 | URL: '', | ||
218 | HOST: '' | ||
219 | }, | ||
220 | TRUST_PROXY: config.get<string[]>('trust_proxy'), | ||
221 | LOG: { | ||
222 | LEVEL: config.get<string>('log.level') | ||
223 | }, | ||
224 | SEARCH: { | ||
225 | REMOTE_URI: { | ||
226 | USERS: config.get<boolean>('search.remote_uri.users'), | ||
227 | ANONYMOUS: config.get<boolean>('search.remote_uri.anonymous') | ||
228 | } | ||
229 | }, | ||
230 | TRENDING: { | ||
231 | VIDEOS: { | ||
232 | INTERVAL_DAYS: config.get<number>('trending.videos.interval_days') | ||
233 | } | ||
234 | }, | ||
235 | REDUNDANCY: { | ||
236 | VIDEOS: { | ||
237 | CHECK_INTERVAL: parseDuration(config.get<string>('redundancy.videos.check_interval')), | ||
238 | STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies')) | ||
239 | } | ||
240 | }, | ||
241 | CSP: { | ||
242 | ENABLED: config.get<boolean>('csp.enabled'), | ||
243 | REPORT_ONLY: config.get<boolean>('csp.report_only'), | ||
244 | REPORT_URI: config.get<boolean>('csp.report_uri') | ||
245 | }, | ||
246 | TRACKER: { | ||
247 | ENABLED: config.get<boolean>('tracker.enabled'), | ||
248 | PRIVATE: config.get<boolean>('tracker.private'), | ||
249 | REJECT_TOO_MANY_ANNOUNCES: config.get<boolean>('tracker.reject_too_many_announces') | ||
250 | }, | ||
251 | ADMIN: { | ||
252 | get EMAIL () { return config.get<string>('admin.email') } | ||
253 | }, | ||
254 | CONTACT_FORM: { | ||
255 | get ENABLED () { return config.get<boolean>('contact_form.enabled') } | ||
256 | }, | ||
257 | SIGNUP: { | ||
258 | get ENABLED () { return config.get<boolean>('signup.enabled') }, | ||
259 | get LIMIT () { return config.get<number>('signup.limit') }, | ||
260 | get REQUIRES_EMAIL_VERIFICATION () { return config.get<boolean>('signup.requires_email_verification') }, | ||
261 | FILTERS: { | ||
262 | CIDR: { | ||
263 | get WHITELIST () { return config.get<string[]>('signup.filters.cidr.whitelist') }, | ||
264 | get BLACKLIST () { return config.get<string[]>('signup.filters.cidr.blacklist') } | ||
265 | } | ||
266 | } | ||
267 | }, | ||
268 | USER: { | ||
269 | get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) }, | ||
270 | get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) } | ||
271 | }, | ||
272 | TRANSCODING: { | ||
273 | get ENABLED () { return config.get<boolean>('transcoding.enabled') }, | ||
274 | get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') }, | ||
275 | get THREADS () { return config.get<number>('transcoding.threads') }, | ||
276 | RESOLUTIONS: { | ||
277 | get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') }, | ||
278 | get '360p' () { return config.get<boolean>('transcoding.resolutions.360p') }, | ||
279 | get '480p' () { return config.get<boolean>('transcoding.resolutions.480p') }, | ||
280 | get '720p' () { return config.get<boolean>('transcoding.resolutions.720p') }, | ||
281 | get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') } | ||
282 | }, | ||
283 | HLS: { | ||
284 | get ENABLED () { return config.get<boolean>('transcoding.hls.enabled') } | ||
285 | } | ||
286 | }, | ||
287 | IMPORT: { | ||
288 | VIDEOS: { | ||
289 | HTTP: { | ||
290 | get ENABLED () { return config.get<boolean>('import.videos.http.enabled') } | ||
291 | }, | ||
292 | TORRENT: { | ||
293 | get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') } | ||
294 | } | ||
295 | } | ||
296 | }, | ||
297 | AUTO_BLACKLIST: { | ||
298 | VIDEOS: { | ||
299 | OF_USERS: { | ||
300 | get ENABLED () { return config.get<boolean>('auto_blacklist.videos.of_users.enabled') } | ||
301 | } | ||
302 | } | ||
303 | }, | ||
304 | CACHE: { | ||
305 | PREVIEWS: { | ||
306 | get SIZE () { return config.get<number>('cache.previews.size') } | ||
307 | }, | ||
308 | VIDEO_CAPTIONS: { | ||
309 | get SIZE () { return config.get<number>('cache.captions.size') } | ||
310 | } | ||
311 | }, | ||
312 | INSTANCE: { | ||
313 | get NAME () { return config.get<string>('instance.name') }, | ||
314 | get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') }, | ||
315 | get DESCRIPTION () { return config.get<string>('instance.description') }, | ||
316 | get TERMS () { return config.get<string>('instance.terms') }, | ||
317 | get IS_NSFW () { return config.get<boolean>('instance.is_nsfw') }, | ||
318 | get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') }, | ||
319 | get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') }, | ||
320 | CUSTOMIZATIONS: { | ||
321 | get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') }, | ||
322 | get CSS () { return config.get<string>('instance.customizations.css') } | ||
323 | }, | ||
324 | get ROBOTS () { return config.get<string>('instance.robots') }, | ||
325 | get SECURITYTXT () { return config.get<string>('instance.securitytxt') }, | ||
326 | get SECURITYTXT_CONTACT () { return config.get<string>('admin.email') } | ||
327 | }, | ||
328 | SERVICES: { | ||
329 | TWITTER: { | ||
330 | get USERNAME () { return config.get<string>('services.twitter.username') }, | ||
331 | get WHITELISTED () { return config.get<boolean>('services.twitter.whitelisted') } | ||
332 | } | ||
333 | }, | ||
334 | FOLLOWERS: { | ||
335 | INSTANCE: { | ||
336 | get ENABLED () { return config.get<boolean>('followers.instance.enabled') }, | ||
337 | get MANUAL_APPROVAL () { return config.get<boolean>('followers.instance.manual_approval') } | ||
338 | } | ||
339 | } | ||
340 | } | ||
341 | |||
342 | // --------------------------------------------------------------------------- | ||
343 | |||
344 | let CONSTRAINTS_FIELDS = { | 171 | let CONSTRAINTS_FIELDS = { |
345 | USERS: { | 172 | USERS: { |
346 | NAME: { min: 1, max: 120 }, // Length | 173 | NAME: { min: 1, max: 120 }, // Length |
@@ -517,38 +344,38 @@ const VIDEO_LICENCES = { | |||
517 | const VIDEO_LANGUAGES = buildLanguages() | 344 | const VIDEO_LANGUAGES = buildLanguages() |
518 | 345 | ||
519 | const VIDEO_PRIVACIES = { | 346 | const VIDEO_PRIVACIES = { |
520 | [VideoPrivacy.PUBLIC]: 'Public', | 347 | [ VideoPrivacy.PUBLIC ]: 'Public', |
521 | [VideoPrivacy.UNLISTED]: 'Unlisted', | 348 | [ VideoPrivacy.UNLISTED ]: 'Unlisted', |
522 | [VideoPrivacy.PRIVATE]: 'Private' | 349 | [ VideoPrivacy.PRIVATE ]: 'Private' |
523 | } | 350 | } |
524 | 351 | ||
525 | const VIDEO_STATES = { | 352 | const VIDEO_STATES = { |
526 | [VideoState.PUBLISHED]: 'Published', | 353 | [ VideoState.PUBLISHED ]: 'Published', |
527 | [VideoState.TO_TRANSCODE]: 'To transcode', | 354 | [ VideoState.TO_TRANSCODE ]: 'To transcode', |
528 | [VideoState.TO_IMPORT]: 'To import' | 355 | [ VideoState.TO_IMPORT ]: 'To import' |
529 | } | 356 | } |
530 | 357 | ||
531 | const VIDEO_IMPORT_STATES = { | 358 | const VIDEO_IMPORT_STATES = { |
532 | [VideoImportState.FAILED]: 'Failed', | 359 | [ VideoImportState.FAILED ]: 'Failed', |
533 | [VideoImportState.PENDING]: 'Pending', | 360 | [ VideoImportState.PENDING ]: 'Pending', |
534 | [VideoImportState.SUCCESS]: 'Success' | 361 | [ VideoImportState.SUCCESS ]: 'Success' |
535 | } | 362 | } |
536 | 363 | ||
537 | const VIDEO_ABUSE_STATES = { | 364 | const VIDEO_ABUSE_STATES = { |
538 | [VideoAbuseState.PENDING]: 'Pending', | 365 | [ VideoAbuseState.PENDING ]: 'Pending', |
539 | [VideoAbuseState.REJECTED]: 'Rejected', | 366 | [ VideoAbuseState.REJECTED ]: 'Rejected', |
540 | [VideoAbuseState.ACCEPTED]: 'Accepted' | 367 | [ VideoAbuseState.ACCEPTED ]: 'Accepted' |
541 | } | 368 | } |
542 | 369 | ||
543 | const VIDEO_PLAYLIST_PRIVACIES = { | 370 | const VIDEO_PLAYLIST_PRIVACIES = { |
544 | [VideoPlaylistPrivacy.PUBLIC]: 'Public', | 371 | [ VideoPlaylistPrivacy.PUBLIC ]: 'Public', |
545 | [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted', | 372 | [ VideoPlaylistPrivacy.UNLISTED ]: 'Unlisted', |
546 | [VideoPlaylistPrivacy.PRIVATE]: 'Private' | 373 | [ VideoPlaylistPrivacy.PRIVATE ]: 'Private' |
547 | } | 374 | } |
548 | 375 | ||
549 | const VIDEO_PLAYLIST_TYPES = { | 376 | const VIDEO_PLAYLIST_TYPES = { |
550 | [VideoPlaylistType.REGULAR]: 'Regular', | 377 | [ VideoPlaylistType.REGULAR ]: 'Regular', |
551 | [VideoPlaylistType.WATCH_LATER]: 'Watch later' | 378 | [ VideoPlaylistType.WATCH_LATER ]: 'Watch later' |
552 | } | 379 | } |
553 | 380 | ||
554 | const MIMETYPES = { | 381 | const MIMETYPES = { |
@@ -634,7 +461,7 @@ const USER_PASSWORD_RESET_LIFETIME = 60000 * 5 // 5 minutes | |||
634 | 461 | ||
635 | const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes | 462 | const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes |
636 | 463 | ||
637 | const NSFW_POLICY_TYPES: { [ id: string]: NSFWPolicyType } = { | 464 | const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = { |
638 | DO_NOT_LIST: 'do_not_list', | 465 | DO_NOT_LIST: 'do_not_list', |
639 | BLUR: 'blur', | 466 | BLUR: 'blur', |
640 | DISPLAY: 'display' | 467 | DISPLAY: 'display' |
@@ -765,14 +592,14 @@ if (isTestInstance() === true) { | |||
765 | SCHEDULER_INTERVALS_MS.actorFollowScores = 1000 | 592 | SCHEDULER_INTERVALS_MS.actorFollowScores = 1000 |
766 | SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 | 593 | SCHEDULER_INTERVALS_MS.removeOldJobs = 10000 |
767 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 | 594 | SCHEDULER_INTERVALS_MS.updateVideos = 5000 |
768 | REPEAT_JOBS['videos-views'] = { every: 5000 } | 595 | REPEAT_JOBS[ 'videos-views' ] = { every: 5000 } |
769 | 596 | ||
770 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 | 597 | REDUNDANCY.VIDEOS.RANDOMIZED_FACTOR = 1 |
771 | 598 | ||
772 | VIDEO_VIEW_LIFETIME = 1000 // 1 second | 599 | VIDEO_VIEW_LIFETIME = 1000 // 1 second |
773 | CONTACT_FORM_LIFETIME = 1000 // 1 second | 600 | CONTACT_FORM_LIFETIME = 1000 // 1 second |
774 | 601 | ||
775 | JOB_ATTEMPTS['email'] = 1 | 602 | JOB_ATTEMPTS[ 'email' ] = 1 |
776 | 603 | ||
777 | FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 | 604 | FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE = 3000 |
778 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 | 605 | MEMOIZE_TTL.OVERVIEWS_SAMPLE = 1 |
@@ -783,9 +610,15 @@ if (isTestInstance() === true) { | |||
783 | 610 | ||
784 | updateWebserverUrls() | 611 | updateWebserverUrls() |
785 | 612 | ||
613 | registerConfigChangedHandler(() => { | ||
614 | updateWebserverUrls() | ||
615 | updateWebserverConfig() | ||
616 | }) | ||
617 | |||
786 | // --------------------------------------------------------------------------- | 618 | // --------------------------------------------------------------------------- |
787 | 619 | ||
788 | export { | 620 | export { |
621 | WEBSERVER, | ||
789 | API_VERSION, | 622 | API_VERSION, |
790 | HLS_REDUNDANCY_DIRECTORY, | 623 | HLS_REDUNDANCY_DIRECTORY, |
791 | P2P_MEDIA_LOADER_PEER_VERSION, | 624 | P2P_MEDIA_LOADER_PEER_VERSION, |
@@ -794,7 +627,6 @@ export { | |||
794 | BCRYPT_SALT_SIZE, | 627 | BCRYPT_SALT_SIZE, |
795 | TRACKER_RATE_LIMITS, | 628 | TRACKER_RATE_LIMITS, |
796 | FILES_CACHE, | 629 | FILES_CACHE, |
797 | CONFIG, | ||
798 | CONSTRAINTS_FIELDS, | 630 | CONSTRAINTS_FIELDS, |
799 | EMBED_SIZE, | 631 | EMBED_SIZE, |
800 | REDUNDANCY, | 632 | REDUNDANCY, |
@@ -857,17 +689,6 @@ export { | |||
857 | 689 | ||
858 | // --------------------------------------------------------------------------- | 690 | // --------------------------------------------------------------------------- |
859 | 691 | ||
860 | function getLocalConfigFilePath () { | ||
861 | const configSources = config.util.getConfigSources() | ||
862 | if (configSources.length === 0) throw new Error('Invalid config source.') | ||
863 | |||
864 | let filename = 'local' | ||
865 | if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}` | ||
866 | if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}` | ||
867 | |||
868 | return join(dirname(configSources[ 0 ].name), filename + '.json') | ||
869 | } | ||
870 | |||
871 | function buildVideoMimetypeExt () { | 692 | function buildVideoMimetypeExt () { |
872 | const data = { | 693 | const data = { |
873 | 'video/webm': '.webm', | 694 | 'video/webm': '.webm', |
@@ -890,8 +711,12 @@ function buildVideoMimetypeExt () { | |||
890 | } | 711 | } |
891 | 712 | ||
892 | function updateWebserverUrls () { | 713 | function updateWebserverUrls () { |
893 | CONFIG.WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT) | 714 | WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT) |
894 | CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP) | 715 | WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP) |
716 | WEBSERVER.SCHEME = CONFIG.WEBSERVER.SCHEME | ||
717 | WEBSERVER.WS = CONFIG.WEBSERVER.WS | ||
718 | WEBSERVER.HOSTNAME = CONFIG.WEBSERVER.HOSTNAME | ||
719 | WEBSERVER.PORT = CONFIG.WEBSERVER.PORT | ||
895 | } | 720 | } |
896 | 721 | ||
897 | function updateWebserverConfig () { | 722 | function updateWebserverConfig () { |
@@ -907,20 +732,6 @@ function buildVideosExtname () { | |||
907 | : [ '.mp4', '.ogv', '.webm' ] | 732 | : [ '.mp4', '.ogv', '.webm' ] |
908 | } | 733 | } |
909 | 734 | ||
910 | function buildVideosRedundancy (objs: any[]): VideosRedundancy[] { | ||
911 | if (!objs) return [] | ||
912 | |||
913 | if (!Array.isArray(objs)) return objs | ||
914 | |||
915 | return objs.map(obj => { | ||
916 | return Object.assign({}, obj, { | ||
917 | minLifetime: parseDuration(obj.min_lifetime), | ||
918 | size: bytes.parse(obj.size), | ||
919 | minViews: obj.min_views | ||
920 | }) | ||
921 | }) | ||
922 | } | ||
923 | |||
924 | function buildLanguages () { | 735 | function buildLanguages () { |
925 | const iso639 = require('iso-639-3') | 736 | const iso639 = require('iso-639-3') |
926 | 737 | ||
@@ -953,42 +764,12 @@ function buildLanguages () { | |||
953 | iso639 | 764 | iso639 |
954 | .filter(l => { | 765 | .filter(l => { |
955 | return (l.iso6391 !== null && l.type === 'living') || | 766 | return (l.iso6391 !== null && l.type === 'living') || |
956 | additionalLanguages[l.iso6393] === true | 767 | additionalLanguages[ l.iso6393 ] === true |
957 | }) | 768 | }) |
958 | .forEach(l => languages[l.iso6391 || l.iso6393] = l.name) | 769 | .forEach(l => languages[ l.iso6391 || l.iso6393 ] = l.name) |
959 | 770 | ||
960 | // Override Occitan label | 771 | // Override Occitan label |
961 | languages['oc'] = 'Occitan' | 772 | languages[ 'oc' ] = 'Occitan' |
962 | 773 | ||
963 | return languages | 774 | return languages |
964 | } | 775 | } |
965 | |||
966 | export function reloadConfig () { | ||
967 | |||
968 | function directory () { | ||
969 | if (process.env.NODE_CONFIG_DIR) { | ||
970 | return process.env.NODE_CONFIG_DIR | ||
971 | } | ||
972 | |||
973 | return join(root(), 'config') | ||
974 | } | ||
975 | |||
976 | function purge () { | ||
977 | for (const fileName in require.cache) { | ||
978 | if (-1 === fileName.indexOf(directory())) { | ||
979 | continue | ||
980 | } | ||
981 | |||
982 | delete require.cache[fileName] | ||
983 | } | ||
984 | |||
985 | delete require.cache[require.resolve('config')] | ||
986 | } | ||
987 | |||
988 | purge() | ||
989 | |||
990 | config = require('config') | ||
991 | |||
992 | updateWebserverConfig() | ||
993 | updateWebserverUrls() | ||
994 | } | ||
diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 541ebbecf..872a56220 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts | |||
@@ -21,7 +21,7 @@ import { VideoCommentModel } from '../models/video/video-comment' | |||
21 | import { VideoFileModel } from '../models/video/video-file' | 21 | import { VideoFileModel } from '../models/video/video-file' |
22 | import { VideoShareModel } from '../models/video/video-share' | 22 | import { VideoShareModel } from '../models/video/video-share' |
23 | import { VideoTagModel } from '../models/video/video-tag' | 23 | import { VideoTagModel } from '../models/video/video-tag' |
24 | import { CONFIG } from './constants' | 24 | import { CONFIG } from './config' |
25 | import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update' | 25 | import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update' |
26 | import { VideoCaptionModel } from '../models/video/video-caption' | 26 | import { VideoCaptionModel } from '../models/video/video-caption' |
27 | import { VideoImportModel } from '../models/video/video-import' | 27 | import { VideoImportModel } from '../models/video/video-import' |
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 07af96b68..127449577 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -6,9 +6,10 @@ import { UserModel } from '../models/account/user' | |||
6 | import { ApplicationModel } from '../models/application/application' | 6 | import { ApplicationModel } from '../models/application/application' |
7 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 7 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
8 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' | 8 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' |
9 | import { FILES_CACHE, CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants' | 9 | import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants' |
10 | import { sequelizeTypescript } from './database' | 10 | import { sequelizeTypescript } from './database' |
11 | import { remove, ensureDir } from 'fs-extra' | 11 | import { ensureDir, remove } from 'fs-extra' |
12 | import { CONFIG } from './config' | ||
12 | 13 | ||
13 | async function installApplication () { | 14 | async function installApplication () { |
14 | try { | 15 | try { |
diff --git a/server/initializers/migrations/0075-video-resolutions.ts b/server/initializers/migrations/0075-video-resolutions.ts index 26a188e5e..e4f26cb77 100644 --- a/server/initializers/migrations/0075-video-resolutions.ts +++ b/server/initializers/migrations/0075-video-resolutions.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { CONFIG } from '../../initializers/constants' | 3 | import { CONFIG } from '../../initializers/config' |
4 | import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' | 4 | import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' |
5 | import { readdir, rename } from 'fs-extra' | 5 | import { readdir, rename } from 'fs-extra' |
6 | 6 | ||
diff --git a/server/initializers/migrations/0140-actor-url.ts b/server/initializers/migrations/0140-actor-url.ts index e64ee3487..020499391 100644 --- a/server/initializers/migrations/0140-actor-url.ts +++ b/server/initializers/migrations/0140-actor-url.ts | |||
@@ -1,13 +1,13 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { CONFIG } from '../constants' | 2 | import { WEBSERVER } from '../constants' |
3 | 3 | ||
4 | async function up (utils: { | 4 | async function up (utils: { |
5 | transaction: Sequelize.Transaction, | 5 | transaction: Sequelize.Transaction, |
6 | queryInterface: Sequelize.QueryInterface, | 6 | queryInterface: Sequelize.QueryInterface, |
7 | sequelize: Sequelize.Sequelize | 7 | sequelize: Sequelize.Sequelize |
8 | }): Promise<void> { | 8 | }): Promise<void> { |
9 | const toReplace = CONFIG.WEBSERVER.HOSTNAME + ':443' | 9 | const toReplace = WEBSERVER.HOSTNAME + ':443' |
10 | const by = CONFIG.WEBSERVER.HOST | 10 | const by = WEBSERVER.HOST |
11 | const replacer = column => `replace("${column}", '${toReplace}', '${by}')` | 11 | const replacer = column => `replace("${column}", '${toReplace}', '${by}')` |
12 | 12 | ||
13 | { | 13 | { |
diff --git a/server/initializers/migrations/0235-delete-some-video-indexes.ts b/server/initializers/migrations/0235-delete-some-video-indexes.ts index e362f240c..5964b0dc5 100644 --- a/server/initializers/migrations/0235-delete-some-video-indexes.ts +++ b/server/initializers/migrations/0235-delete-some-video-indexes.ts | |||
@@ -1,8 +1,4 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { createClient } from 'redis' | ||
3 | import { CONFIG } from '../constants' | ||
4 | import { JobQueue } from '../../lib/job-queue' | ||
5 | import { initDatabaseModels } from '../database' | ||
6 | 2 | ||
7 | async function up (utils: { | 3 | async function up (utils: { |
8 | transaction: Sequelize.Transaction | 4 | transaction: Sequelize.Transaction |
diff --git a/server/initializers/migrations/0240-drop-old-indexes.ts b/server/initializers/migrations/0240-drop-old-indexes.ts index ba961e3f9..39868fa2d 100644 --- a/server/initializers/migrations/0240-drop-old-indexes.ts +++ b/server/initializers/migrations/0240-drop-old-indexes.ts | |||
@@ -1,8 +1,4 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { createClient } from 'redis' | ||
3 | import { CONFIG } from '../constants' | ||
4 | import { JobQueue } from '../../lib/job-queue' | ||
5 | import { initDatabaseModels } from '../database' | ||
6 | 2 | ||
7 | async function up (utils: { | 3 | async function up (utils: { |
8 | transaction: Sequelize.Transaction | 4 | transaction: Sequelize.Transaction |
diff --git a/server/initializers/migrations/0345-video-playlists.ts b/server/initializers/migrations/0345-video-playlists.ts index 11670b11d..6953f5553 100644 --- a/server/initializers/migrations/0345-video-playlists.ts +++ b/server/initializers/migrations/0345-video-playlists.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { CONFIG } from '../constants' | ||
3 | import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' | 2 | import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' |
4 | import * as uuidv4 from 'uuid/v4' | 3 | import * as uuidv4 from 'uuid/v4' |
4 | import { WEBSERVER } from '../constants' | ||
5 | 5 | ||
6 | async function up (utils: { | 6 | async function up (utils: { |
7 | transaction: Sequelize.Transaction, | 7 | transaction: Sequelize.Transaction, |
@@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS "videoPlaylistElement" | |||
57 | for (const username of usernames) { | 57 | for (const username of usernames) { |
58 | const uuid = uuidv4() | 58 | const uuid = uuidv4() |
59 | 59 | ||
60 | const baseUrl = CONFIG.WEBSERVER.URL + '/video-playlists/' + uuid | 60 | const baseUrl = WEBSERVER.URL + '/video-playlists/' + uuid |
61 | const query = ` | 61 | const query = ` |
62 | INSERT INTO "videoPlaylist" ("url", "uuid", "name", "privacy", "type", "ownerAccountId", "createdAt", "updatedAt") | 62 | INSERT INTO "videoPlaylist" ("url", "uuid", "name", "privacy", "type", "ownerAccountId", "createdAt", "updatedAt") |
63 | SELECT '${baseUrl}' AS "url", | 63 | SELECT '${baseUrl}' AS "url", |
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 |
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 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import { sendUpdateActor } from './activitypub/send' | 2 | import { sendUpdateActor } from './activitypub/send' |
3 | import { AVATARS_SIZE, CONFIG, sequelizeTypescript } from '../initializers' | 3 | import { AVATARS_SIZE, sequelizeTypescript } from '../initializers' |
4 | import { updateActorAvatarInstance } from './activitypub' | 4 | import { updateActorAvatarInstance } from './activitypub' |
5 | import { processImage } from '../helpers/image-utils' | 5 | import { processImage } from '../helpers/image-utils' |
6 | import { AccountModel } from '../models/account/account' | 6 | import { AccountModel } from '../models/account/account' |
@@ -8,6 +8,7 @@ import { VideoChannelModel } from '../models/video/video-channel' | |||
8 | import { extname, join } from 'path' | 8 | import { extname, join } from 'path' |
9 | import { retryTransactionWrapper } from '../helpers/database-utils' | 9 | import { retryTransactionWrapper } from '../helpers/database-utils' |
10 | import * as uuidv4 from 'uuid/v4' | 10 | import * as uuidv4 from 'uuid/v4' |
11 | import { CONFIG } from '../initializers/config' | ||
11 | 12 | ||
12 | async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) { | 13 | async 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' | 2 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' |
3 | import { CONFIG, CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE } from '../initializers' | 3 | import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, WEBSERVER } from '../initializers' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { escapeHTML } from '../helpers/core-utils' | 5 | import { escapeHTML } from '../helpers/core-utils' |
6 | import { VideoModel } from '../models/video/video' | 6 | import { VideoModel } from '../models/video/video' |
@@ -11,6 +11,7 @@ import { getActivityStreamDuration } from '../models/video/video-format-utils' | |||
11 | import { AccountModel } from '../models/account/account' | 11 | import { AccountModel } from '../models/account/account' |
12 | import { VideoChannelModel } from '../models/video/video-channel' | 12 | import { VideoChannelModel } from '../models/video/video-channel' |
13 | import * as Bluebird from 'bluebird' | 13 | import * as Bluebird from 'bluebird' |
14 | import { CONFIG } from '../initializers/config' | ||
14 | 15 | ||
15 | export class ClientHtml { | 16 | export 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 @@ | |||
1 | import { createTransport, Transporter } from 'nodemailer' | 1 | import { createTransport, Transporter } from 'nodemailer' |
2 | import { isTestInstance } from '../helpers/core-utils' | 2 | import { isTestInstance } from '../helpers/core-utils' |
3 | import { bunyanLogger, logger } from '../helpers/logger' | 3 | import { bunyanLogger, logger } from '../helpers/logger' |
4 | import { CONFIG } from '../initializers' | 4 | import { CONFIG } from '../initializers/config' |
5 | import { UserModel } from '../models/account/user' | 5 | import { UserModel } from '../models/account/user' |
6 | import { VideoModel } from '../models/video/video' | 6 | import { VideoModel } from '../models/video/video' |
7 | import { JobQueue } from './job-queue' | 7 | import { JobQueue } from './job-queue' |
@@ -12,6 +12,7 @@ import { VideoAbuseModel } from '../models/video/video-abuse' | |||
12 | import { VideoBlacklistModel } from '../models/video/video-blacklist' | 12 | import { VideoBlacklistModel } from '../models/video/video-blacklist' |
13 | import { VideoImportModel } from '../models/video/video-import' | 13 | import { VideoImportModel } from '../models/video/video-import' |
14 | import { ActorFollowModel } from '../models/activitypub/actor-follow' | 14 | import { ActorFollowModel } from '../models/activitypub/actor-follow' |
15 | import { WEBSERVER } from '../initializers/constants' | ||
15 | 16 | ||
16 | type SendEmailOptions = { | 17 | type 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 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { FILES_CACHE, CONFIG } from '../../initializers' | 2 | import { FILES_CACHE } from '../../initializers' |
3 | import { VideoModel } from '../../models/video/video' | 3 | import { VideoModel } from '../../models/video/video' |
4 | import { VideoCaptionModel } from '../../models/video/video-caption' | 4 | import { VideoCaptionModel } from '../../models/video/video-caption' |
5 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' | 5 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' |
6 | import { CONFIG } from '../../initializers/config' | ||
6 | 7 | ||
7 | type GetPathParam = { videoId: string, language: string } | 8 | type 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 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { FILES_CACHE, CONFIG, STATIC_PATHS } from '../../initializers' | 2 | import { FILES_CACHE, STATIC_PATHS } from '../../initializers' |
3 | import { VideoModel } from '../../models/video/video' | 3 | import { VideoModel } from '../../models/video/video' |
4 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' | 4 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' |
5 | import { CONFIG } from '../../initializers/config' | ||
5 | 6 | ||
6 | class VideosPreviewCache extends AbstractVideoStaticFileCache <string> { | 7 | class 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 @@ | |||
1 | import { VideoModel } from '../models/video/video' | 1 | import { VideoModel } from '../models/video/video' |
2 | import { basename, dirname, join } from 'path' | 2 | import { basename, dirname, join } from 'path' |
3 | import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers' | 3 | import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers' |
4 | import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' | 4 | import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' |
5 | import { getVideoFileSize } from '../helpers/ffmpeg-utils' | 5 | import { getVideoFileSize } from '../helpers/ffmpeg-utils' |
6 | import { sha256 } from '../helpers/core-utils' | 6 | import { sha256 } from '../helpers/core-utils' |
@@ -10,6 +10,7 @@ import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' | |||
10 | import { generateRandomString } from '../helpers/utils' | 10 | import { generateRandomString } from '../helpers/utils' |
11 | import { flatten, uniq } from 'lodash' | 11 | import { flatten, uniq } from 'lodash' |
12 | import { VideoFileModel } from '../models/video/video-file' | 12 | import { VideoFileModel } from '../models/video/video-file' |
13 | import { CONFIG } from '../initializers/config' | ||
13 | 14 | ||
14 | async function updateStreamingPlaylistsInfohashesIfNeeded () { | 15 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
3 | import { CONFIG, REMOTE_SCHEME, sequelizeTypescript } from '../../../initializers' | 3 | import { REMOTE_SCHEME, sequelizeTypescript, WEBSERVER } from '../../../initializers' |
4 | import { sendFollow } from '../../activitypub/send' | 4 | import { sendFollow } from '../../activitypub/send' |
5 | import { sanitizeHost } from '../../../helpers/core-utils' | 5 | import { sanitizeHost } from '../../../helpers/core-utils' |
6 | import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' | 6 | import { 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' | |||
6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
7 | import { extname, join } from 'path' | 7 | import { extname, join } from 'path' |
8 | import { VideoFileModel } from '../../../models/video/video-file' | 8 | import { VideoFileModel } from '../../../models/video/video-file' |
9 | import { CONFIG, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' | 9 | import { PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' |
10 | import { downloadImage } from '../../../helpers/requests' | 10 | import { downloadImage } from '../../../helpers/requests' |
11 | import { VideoState } from '../../../../shared' | 11 | import { VideoState } from '../../../../shared' |
12 | import { JobQueue } from '../index' | 12 | import { JobQueue } from '../index' |
@@ -14,8 +14,9 @@ import { federateVideoIfNeeded } from '../../activitypub' | |||
14 | import { VideoModel } from '../../../models/video/video' | 14 | import { VideoModel } from '../../../models/video/video' |
15 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' | 15 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' |
16 | import { getSecureTorrentName } from '../../../helpers/utils' | 16 | import { getSecureTorrentName } from '../../../helpers/utils' |
17 | import { remove, move, stat } from 'fs-extra' | 17 | import { move, remove, stat } from 'fs-extra' |
18 | import { Notifier } from '../../notifier' | 18 | import { Notifier } from '../../notifier' |
19 | import { CONFIG } from '../../../initializers/config' | ||
19 | 20 | ||
20 | type VideoImportYoutubeDLPayload = { | 21 | type 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' | |||
5 | import { JobQueue } from '../job-queue' | 5 | import { JobQueue } from '../job-queue' |
6 | import { federateVideoIfNeeded } from '../../activitypub' | 6 | import { federateVideoIfNeeded } from '../../activitypub' |
7 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 7 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
8 | import { CONFIG, sequelizeTypescript } from '../../../initializers' | 8 | import { sequelizeTypescript } from '../../../initializers' |
9 | import * as Bluebird from 'bluebird' | 9 | import * as Bluebird from 'bluebird' |
10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' | 10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' |
11 | import { generateHlsPlaylist, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding' | 11 | import { generateHlsPlaylist, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding' |
12 | import { Notifier } from '../../notifier' | 12 | import { Notifier } from '../../notifier' |
13 | import { CONFIG } from '../../../initializers/config' | ||
13 | 14 | ||
14 | export type VideoTranscodingPayload = { | 15 | export 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' | |||
2 | import { JobState, JobType } from '../../../shared/models' | 2 | import { JobState, JobType } from '../../../shared/models' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { Redis } from '../redis' | 4 | import { Redis } from '../redis' |
5 | import { CONFIG, JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS } from '../../initializers' | 5 | import { JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers' |
6 | import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' | 6 | import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' |
7 | import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' | 7 | import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' |
8 | import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' | 8 | import { 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' | |||
6 | import { VideoCommentModel } from '../models/video/video-comment' | 6 | import { VideoCommentModel } from '../models/video/video-comment' |
7 | import { UserModel } from '../models/account/user' | 7 | import { UserModel } from '../models/account/user' |
8 | import { PeerTubeSocket } from './peertube-socket' | 8 | import { PeerTubeSocket } from './peertube-socket' |
9 | import { CONFIG } from '../initializers/constants' | 9 | import { CONFIG } from '../initializers/config' |
10 | import { VideoPrivacy, VideoState } from '../../shared/models/videos' | 10 | import { VideoPrivacy, VideoState } from '../../shared/models/videos' |
11 | import { VideoAbuseModel } from '../models/video/video-abuse' | 11 | import { VideoAbuseModel } from '../models/video/video-abuse' |
12 | import { VideoBlacklistModel } from '../models/video/video-blacklist' | 12 | import { 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' | |||
4 | import { UserModel } from '../models/account/user' | 4 | import { UserModel } from '../models/account/user' |
5 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 5 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
6 | import { OAuthTokenModel } from '../models/oauth/oauth-token' | 6 | import { OAuthTokenModel } from '../models/oauth/oauth-token' |
7 | import { CONFIG, CACHE } from '../initializers/constants' | 7 | import { CACHE } from '../initializers/constants' |
8 | import { Transaction } from 'sequelize' | 8 | import { Transaction } from 'sequelize' |
9 | import { CONFIG } from '../initializers/config' | ||
9 | 10 | ||
10 | type TokenInfo = { accessToken: string, refreshToken: string, accessTokenExpiresAt: Date, refreshTokenExpiresAt: Date } | 11 | type TokenInfo = { accessToken: string, refreshToken: string, accessTokenExpiresAt: Date, refreshTokenExpiresAt: Date } |
11 | let accessTokenCache: { [ accessToken: string ]: OAuthTokenModel } = {} | 12 | let 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' | |||
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | import { generateRandomString } from '../helpers/utils' | 4 | import { generateRandomString } from '../helpers/utils' |
5 | import { | 5 | import { |
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' |
12 | import { CONFIG } from '../initializers/config' | ||
12 | 13 | ||
13 | type CachedRoute = { | 14 | type 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 @@ | |||
1 | import { AbstractScheduler } from './abstract-scheduler' | 1 | import { AbstractScheduler } from './abstract-scheduler' |
2 | import { CONFIG, HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers' | 2 | import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT, WEBSERVER } from '../../initializers' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { VideosRedundancy } from '../../../shared/models/redundancy' | 4 | import { VideosRedundancy } from '../../../shared/models/redundancy' |
5 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | 5 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' |
@@ -15,6 +15,7 @@ import { getOrCreateVideoAndAccountAndChannel } from '../activitypub' | |||
15 | import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist' | 15 | import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist' |
16 | import { VideoModel } from '../../models/video/video' | 16 | import { VideoModel } from '../../models/video/video' |
17 | import { downloadPlaylistSegments } from '../hls' | 17 | import { downloadPlaylistSegments } from '../hls' |
18 | import { CONFIG } from '../../initializers/config' | ||
18 | 19 | ||
19 | type CandidateToDuplicate = { | 20 | type 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 @@ | |||
1 | import * as sequelize from 'sequelize' | 1 | import * as sequelize from 'sequelize' |
2 | import { CONFIG } from '../initializers/constants' | 2 | import { CONFIG } from '../initializers/config' |
3 | import { VideoBlacklistType, UserRight } from '../../shared/models' | 3 | import { VideoBlacklistType, UserRight } from '../../shared/models' |
4 | import { VideoBlacklistModel } from '../models/video/video-blacklist' | 4 | import { VideoBlacklistModel } from '../models/video/video-blacklist' |
5 | import { UserModel } from '../models/account/user' | 5 | import { 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 @@ | |||
1 | import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION } from '../initializers' | 1 | import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' | 3 | import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' |
4 | import { ensureDir, move, remove, stat } from 'fs-extra' | 4 | import { ensureDir, move, remove, stat } from 'fs-extra' |
@@ -9,6 +9,7 @@ import { VideoModel } from '../models/video/video' | |||
9 | import { updateMasterHLSPlaylist, updateSha256Segments } from './hls' | 9 | import { updateMasterHLSPlaylist, updateSha256Segments } from './hls' |
10 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' | 10 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' |
11 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' | 11 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' |
12 | import { CONFIG } from '../initializers/config' | ||
12 | 13 | ||
13 | async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { | 14 | async 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 | ||
diff --git a/server/middlewares/csp.ts b/server/middlewares/csp.ts index 404e33b43..d484b3021 100644 --- a/server/middlewares/csp.ts +++ b/server/middlewares/csp.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as helmet from 'helmet' | 1 | import * as helmet from 'helmet' |
2 | import { CONFIG } from '../initializers/constants' | 2 | import { CONFIG } from '../initializers/config' |
3 | 3 | ||
4 | const baseDirectives = Object.assign({}, | 4 | const baseDirectives = Object.assign({}, |
5 | { | 5 | { |
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts index f5b295f45..7c494de78 100644 --- a/server/middlewares/validators/blocklist.ts +++ b/server/middlewares/validators/blocklist.ts | |||
@@ -3,13 +3,12 @@ import * as express from 'express' | |||
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { areValidationErrors } from './utils' | 4 | import { areValidationErrors } from './utils' |
5 | import { doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' | 5 | import { doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' |
6 | import { UserModel } from '../../models/account/user' | ||
7 | import { AccountBlocklistModel } from '../../models/account/account-blocklist' | 6 | import { AccountBlocklistModel } from '../../models/account/account-blocklist' |
8 | import { isHostValid } from '../../helpers/custom-validators/servers' | 7 | import { isHostValid } from '../../helpers/custom-validators/servers' |
9 | import { ServerBlocklistModel } from '../../models/server/server-blocklist' | 8 | import { ServerBlocklistModel } from '../../models/server/server-blocklist' |
10 | import { ServerModel } from '../../models/server/server' | 9 | import { ServerModel } from '../../models/server/server' |
11 | import { CONFIG } from '../../initializers' | ||
12 | import { getServerActor } from '../../helpers/utils' | 10 | import { getServerActor } from '../../helpers/utils' |
11 | import { WEBSERVER } from '../../initializers/constants' | ||
13 | 12 | ||
14 | const blockAccountValidator = [ | 13 | const blockAccountValidator = [ |
15 | body('accountName').exists().withMessage('Should have an account name with host'), | 14 | body('accountName').exists().withMessage('Should have an account name with host'), |
@@ -79,7 +78,7 @@ const blockServerValidator = [ | |||
79 | 78 | ||
80 | const host: string = req.body.host | 79 | const host: string = req.body.host |
81 | 80 | ||
82 | if (host === CONFIG.WEBSERVER.HOST) { | 81 | if (host === WEBSERVER.HOST) { |
83 | return res.status(409) | 82 | return res.status(409) |
84 | .send({ error: 'You cannot block your own server.' }) | 83 | .send({ error: 'You cannot block your own server.' }) |
85 | .end() | 84 | .end() |
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts index b360cf95e..5623b4ba6 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/middlewares/validators/follows.ts | |||
@@ -4,7 +4,7 @@ import { isTestInstance } from '../../helpers/core-utils' | |||
4 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' | 4 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' |
5 | import { logger } from '../../helpers/logger' | 5 | import { logger } from '../../helpers/logger' |
6 | import { getServerActor } from '../../helpers/utils' | 6 | import { getServerActor } from '../../helpers/utils' |
7 | import { CONFIG, SERVER_ACTOR_NAME } from '../../initializers' | 7 | import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers' |
8 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | 8 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
9 | import { areValidationErrors } from './utils' | 9 | import { areValidationErrors } from './utils' |
10 | import { ActorModel } from '../../models/activitypub/actor' | 10 | import { ActorModel } from '../../models/activitypub/actor' |
@@ -16,7 +16,7 @@ const followValidator = [ | |||
16 | 16 | ||
17 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 17 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
18 | // Force https if the administrator wants to make friends | 18 | // Force https if the administrator wants to make friends |
19 | if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') { | 19 | if (isTestInstance() === false && WEBSERVER.SCHEME === 'http') { |
20 | return res.status(500) | 20 | return res.status(500) |
21 | .json({ | 21 | .json({ |
22 | error: 'Cannot follow on a non HTTPS web server.' | 22 | error: 'Cannot follow on a non HTTPS web server.' |
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts index c89bc26de..0bb908d0b 100644 --- a/server/middlewares/validators/oembed.ts +++ b/server/middlewares/validators/oembed.ts | |||
@@ -5,10 +5,10 @@ import { isTestInstance } from '../../helpers/core-utils' | |||
5 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | 5 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' |
6 | import { doesVideoExist } from '../../helpers/custom-validators/videos' | 6 | import { doesVideoExist } from '../../helpers/custom-validators/videos' |
7 | import { logger } from '../../helpers/logger' | 7 | import { logger } from '../../helpers/logger' |
8 | import { CONFIG } from '../../initializers' | ||
9 | import { areValidationErrors } from './utils' | 8 | import { areValidationErrors } from './utils' |
9 | import { WEBSERVER } from '../../initializers/constants' | ||
10 | 10 | ||
11 | const urlShouldStartWith = CONFIG.WEBSERVER.SCHEME + '://' + join(CONFIG.WEBSERVER.HOST, 'videos', 'watch') + '/' | 11 | const urlShouldStartWith = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch') + '/' |
12 | const videoWatchRegex = new RegExp('([^/]+)$') | 12 | const videoWatchRegex = new RegExp('([^/]+)$') |
13 | const isURLOptions = { | 13 | const isURLOptions = { |
14 | require_host: true, | 14 | require_host: true, |
diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts index e62a17163..6eff8e9ee 100644 --- a/server/middlewares/validators/server.ts +++ b/server/middlewares/validators/server.ts | |||
@@ -7,7 +7,7 @@ import { body } from 'express-validator/check' | |||
7 | import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' | 7 | import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' |
8 | import { Emailer } from '../../lib/emailer' | 8 | import { Emailer } from '../../lib/emailer' |
9 | import { Redis } from '../../lib/redis' | 9 | import { Redis } from '../../lib/redis' |
10 | import { CONFIG } from '../../initializers/constants' | 10 | import { CONFIG } from '../../initializers/config' |
11 | 11 | ||
12 | const serverGetValidator = [ | 12 | const serverGetValidator = [ |
13 | body('host').custom(isHostValid).withMessage('Should have a valid host'), | 13 | body('host').custom(isHostValid).withMessage('Should have a valid host'), |
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts index fd82ed017..2356745d7 100644 --- a/server/middlewares/validators/user-subscriptions.ts +++ b/server/middlewares/validators/user-subscriptions.ts | |||
@@ -5,8 +5,8 @@ import { logger } from '../../helpers/logger' | |||
5 | import { areValidationErrors } from './utils' | 5 | import { areValidationErrors } from './utils' |
6 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | 6 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
7 | import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' | 7 | import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' |
8 | import { CONFIG } from '../../initializers' | ||
9 | import { toArray } from '../../helpers/custom-validators/misc' | 8 | import { toArray } from '../../helpers/custom-validators/misc' |
9 | import { WEBSERVER } from '../../initializers/constants' | ||
10 | 10 | ||
11 | const userSubscriptionAddValidator = [ | 11 | const userSubscriptionAddValidator = [ |
12 | body('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'), | 12 | body('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'), |
@@ -43,7 +43,7 @@ const userSubscriptionGetValidator = [ | |||
43 | if (areValidationErrors(req, res)) return | 43 | if (areValidationErrors(req, res)) return |
44 | 44 | ||
45 | let [ name, host ] = req.params.uri.split('@') | 45 | let [ name, host ] = req.params.uri.split('@') |
46 | if (host === CONFIG.WEBSERVER.HOST) host = null | 46 | if (host === WEBSERVER.HOST) host = null |
47 | 47 | ||
48 | const user = res.locals.oauth.token.User | 48 | const user = res.locals.oauth.token.User |
49 | const subscription = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI(user.Account.Actor.id, name, host) | 49 | const subscription = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI(user.Account.Actor.id, name, host) |
diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts index 3d662b20f..fb13f3ceb 100644 --- a/server/middlewares/validators/videos/video-imports.ts +++ b/server/middlewares/validators/videos/video-imports.ts | |||
@@ -7,7 +7,7 @@ import { getCommonVideoEditAttributes } from './videos' | |||
7 | import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports' | 7 | import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports' |
8 | import { cleanUpReqFiles } from '../../../helpers/express-utils' | 8 | import { cleanUpReqFiles } from '../../../helpers/express-utils' |
9 | import { doesVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos' | 9 | import { doesVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos' |
10 | import { CONFIG } from '../../../initializers/constants' | 10 | import { CONFIG } from '../../../initializers/config' |
11 | import { CONSTRAINTS_FIELDS } from '../../../initializers' | 11 | import { CONSTRAINTS_FIELDS } from '../../../initializers' |
12 | 12 | ||
13 | const videoImportAddValidator = getCommonVideoEditAttributes().concat([ | 13 | const videoImportAddValidator = getCommonVideoEditAttributes().concat([ |
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index e247db708..7ce1a922f 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -32,7 +32,7 @@ import { | |||
32 | } from '../../../helpers/custom-validators/videos' | 32 | } from '../../../helpers/custom-validators/videos' |
33 | import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils' | 33 | import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils' |
34 | import { logger } from '../../../helpers/logger' | 34 | import { logger } from '../../../helpers/logger' |
35 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../../initializers' | 35 | import { CONSTRAINTS_FIELDS } from '../../../initializers' |
36 | import { authenticatePromiseIfNeeded } from '../../oauth' | 36 | import { authenticatePromiseIfNeeded } from '../../oauth' |
37 | import { areValidationErrors } from '../utils' | 37 | import { areValidationErrors } from '../utils' |
38 | import { cleanUpReqFiles } from '../../../helpers/express-utils' | 38 | import { cleanUpReqFiles } from '../../../helpers/express-utils' |
@@ -43,6 +43,7 @@ import { AccountModel } from '../../../models/account/account' | |||
43 | import { VideoFetchType } from '../../../helpers/video' | 43 | import { VideoFetchType } from '../../../helpers/video' |
44 | import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search' | 44 | import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search' |
45 | import { getServerActor } from '../../../helpers/utils' | 45 | import { getServerActor } from '../../../helpers/utils' |
46 | import { CONFIG } from '../../../initializers/config' | ||
46 | 47 | ||
47 | const videosAddValidator = getCommonVideoEditAttributes().concat([ | 48 | const videosAddValidator = getCommonVideoEditAttributes().concat([ |
48 | body('videofile') | 49 | body('videofile') |
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 7cc40f631..6f425024e 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -25,9 +25,9 @@ import { getSort, throwIfNotValid } from '../utils' | |||
25 | import { VideoChannelModel } from '../video/video-channel' | 25 | import { VideoChannelModel } from '../video/video-channel' |
26 | import { VideoCommentModel } from '../video/video-comment' | 26 | import { VideoCommentModel } from '../video/video-comment' |
27 | import { UserModel } from './user' | 27 | import { UserModel } from './user' |
28 | import { CONFIG } from '../../initializers' | ||
29 | import { AvatarModel } from '../avatar/avatar' | 28 | import { AvatarModel } from '../avatar/avatar' |
30 | import { VideoPlaylistModel } from '../video/video-playlist' | 29 | import { VideoPlaylistModel } from '../video/video-playlist' |
30 | import { WEBSERVER } from '../../initializers/constants' | ||
31 | 31 | ||
32 | export enum ScopeNames { | 32 | export enum ScopeNames { |
33 | SUMMARY = 'SUMMARY' | 33 | SUMMARY = 'SUMMARY' |
@@ -199,7 +199,7 @@ export class AccountModel extends Model<AccountModel> { | |||
199 | static loadByNameWithHost (nameWithHost: string) { | 199 | static loadByNameWithHost (nameWithHost: string) { |
200 | const [ accountName, host ] = nameWithHost.split('@') | 200 | const [ accountName, host ] = nameWithHost.split('@') |
201 | 201 | ||
202 | if (!host || host === CONFIG.WEBSERVER.HOST) return AccountModel.loadLocalByName(accountName) | 202 | if (!host || host === WEBSERVER.HOST) return AccountModel.loadLocalByName(accountName) |
203 | 203 | ||
204 | return AccountModel.loadByNameAndHost(accountName, host) | 204 | return AccountModel.loadByNameAndHost(accountName, host) |
205 | } | 205 | } |
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index 7d91e8a4a..5472c8b92 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts | |||
@@ -30,7 +30,7 @@ import { | |||
30 | isActorPublicKeyValid | 30 | isActorPublicKeyValid |
31 | } from '../../helpers/custom-validators/activitypub/actor' | 31 | } from '../../helpers/custom-validators/activitypub/actor' |
32 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 32 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
33 | import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' | 33 | import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers' |
34 | import { AccountModel } from '../account/account' | 34 | import { AccountModel } from '../account/account' |
35 | import { AvatarModel } from '../avatar/avatar' | 35 | import { AvatarModel } from '../avatar/avatar' |
36 | import { ServerModel } from '../server/server' | 36 | import { ServerModel } from '../server/server' |
@@ -516,7 +516,7 @@ export class ActorModel extends Model<ActorModel> { | |||
516 | } | 516 | } |
517 | 517 | ||
518 | getHost () { | 518 | getHost () { |
519 | return this.Server ? this.Server.host : CONFIG.WEBSERVER.HOST | 519 | return this.Server ? this.Server.host : WEBSERVER.HOST |
520 | } | 520 | } |
521 | 521 | ||
522 | getRedundancyAllowed () { | 522 | getRedundancyAllowed () { |
@@ -526,7 +526,7 @@ export class ActorModel extends Model<ActorModel> { | |||
526 | getAvatarUrl () { | 526 | getAvatarUrl () { |
527 | if (!this.avatarId) return undefined | 527 | if (!this.avatarId) return undefined |
528 | 528 | ||
529 | return CONFIG.WEBSERVER.URL + this.Avatar.getWebserverPath() | 529 | return WEBSERVER.URL + this.Avatar.getWebserverPath() |
530 | } | 530 | } |
531 | 531 | ||
532 | isOutdated () { | 532 | isOutdated () { |
diff --git a/server/models/avatar/avatar.ts b/server/models/avatar/avatar.ts index 303aebcc2..455835524 100644 --- a/server/models/avatar/avatar.ts +++ b/server/models/avatar/avatar.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' |
3 | import { Avatar } from '../../../shared/models/avatars/avatar.model' | 3 | import { Avatar } from '../../../shared/models/avatars/avatar.model' |
4 | import { CONFIG, STATIC_PATHS } from '../../initializers' | 4 | import { STATIC_PATHS } from '../../initializers' |
5 | import { logger } from '../../helpers/logger' | 5 | import { logger } from '../../helpers/logger' |
6 | import { remove } from 'fs-extra' | 6 | import { remove } from 'fs-extra' |
7 | import { CONFIG } from '../../initializers/config' | ||
7 | 8 | ||
8 | @Table({ | 9 | @Table({ |
9 | tableName: 'avatar' | 10 | tableName: 'avatar' |
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index b722bed14..39c50be5c 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts | |||
@@ -15,7 +15,7 @@ import { | |||
15 | import { ActorModel } from '../activitypub/actor' | 15 | import { ActorModel } from '../activitypub/actor' |
16 | import { getVideoSort, throwIfNotValid } from '../utils' | 16 | import { getVideoSort, throwIfNotValid } from '../utils' |
17 | import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 17 | import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
18 | import { CONFIG, CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers' | 18 | import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers' |
19 | import { VideoFileModel } from '../video/video-file' | 19 | import { VideoFileModel } from '../video/video-file' |
20 | import { getServerActor } from '../../helpers/utils' | 20 | import { getServerActor } from '../../helpers/utils' |
21 | import { VideoModel } from '../video/video' | 21 | import { VideoModel } from '../video/video' |
@@ -29,6 +29,7 @@ import { isTestInstance } from '../../helpers/core-utils' | |||
29 | import * as Bluebird from 'bluebird' | 29 | import * as Bluebird from 'bluebird' |
30 | import * as Sequelize from 'sequelize' | 30 | import * as Sequelize from 'sequelize' |
31 | import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist' | 31 | import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist' |
32 | import { CONFIG } from '../../initializers/config' | ||
32 | 33 | ||
33 | export enum ScopeNames { | 34 | export enum ScopeNames { |
34 | WITH_VIDEO = 'WITH_VIDEO' | 35 | WITH_VIDEO = 'WITH_VIDEO' |
diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.ts index b4f17b481..c670bce71 100644 --- a/server/models/video/video-caption.ts +++ b/server/models/video/video-caption.ts | |||
@@ -16,10 +16,11 @@ import { throwIfNotValid } from '../utils' | |||
16 | import { VideoModel } from './video' | 16 | import { VideoModel } from './video' |
17 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' | 17 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' |
18 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' | 18 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' |
19 | import { CONFIG, STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers' | 19 | import { STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers' |
20 | import { join } from 'path' | 20 | import { join } from 'path' |
21 | import { logger } from '../../helpers/logger' | 21 | import { logger } from '../../helpers/logger' |
22 | import { remove } from 'fs-extra' | 22 | import { remove } from 'fs-extra' |
23 | import { CONFIG } from '../../initializers/config' | ||
23 | 24 | ||
24 | export enum ScopeNames { | 25 | export enum ScopeNames { |
25 | WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE' | 26 | WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE' |
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index ca06048d1..1abc23eaa 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -8,7 +8,8 @@ import { | |||
8 | Default, | 8 | Default, |
9 | DefaultScope, | 9 | DefaultScope, |
10 | ForeignKey, | 10 | ForeignKey, |
11 | HasMany, IFindOptions, | 11 | HasMany, |
12 | IFindOptions, | ||
12 | Is, | 13 | Is, |
13 | Model, | 14 | Model, |
14 | Scopes, | 15 | Scopes, |
@@ -28,7 +29,7 @@ import { AccountModel, ScopeNames as AccountModelScopeNames } from '../account/a | |||
28 | import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' | 29 | import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' |
29 | import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' | 30 | import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' |
30 | import { VideoModel } from './video' | 31 | import { VideoModel } from './video' |
31 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' | 32 | import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers' |
32 | import { ServerModel } from '../server/server' | 33 | import { ServerModel } from '../server/server' |
33 | import { DefineIndexesOptions } from 'sequelize' | 34 | import { DefineIndexesOptions } from 'sequelize' |
34 | import { AvatarModel } from '../avatar/avatar' | 35 | import { AvatarModel } from '../avatar/avatar' |
@@ -419,7 +420,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
419 | static loadByNameWithHostAndPopulateAccount (nameWithHost: string) { | 420 | static loadByNameWithHostAndPopulateAccount (nameWithHost: string) { |
420 | const [ name, host ] = nameWithHost.split('@') | 421 | const [ name, host ] = nameWithHost.split('@') |
421 | 422 | ||
422 | if (!host || host === CONFIG.WEBSERVER.HOST) return VideoChannelModel.loadLocalByNameAndPopulateAccount(name) | 423 | if (!host || host === WEBSERVER.HOST) return VideoChannelModel.loadLocalByNameAndPopulateAccount(name) |
423 | 424 | ||
424 | return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host) | 425 | return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host) |
425 | } | 426 | } |
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 93d84c6fc..47f1cbb99 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -18,7 +18,7 @@ import { ActivityTagObject } from '../../../shared/models/activitypub/objects/co | |||
18 | import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object' | 18 | import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object' |
19 | import { VideoComment } from '../../../shared/models/videos/video-comment.model' | 19 | import { VideoComment } from '../../../shared/models/videos/video-comment.model' |
20 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 20 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
21 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' | 21 | import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers' |
22 | import { sendDeleteVideoComment } from '../../lib/activitypub/send' | 22 | import { sendDeleteVideoComment } from '../../lib/activitypub/send' |
23 | import { AccountModel } from '../account/account' | 23 | import { AccountModel } from '../account/account' |
24 | import { ActorModel } from '../activitypub/actor' | 24 | import { ActorModel } from '../activitypub/actor' |
@@ -482,7 +482,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
482 | let result: string[] = [] | 482 | let result: string[] = [] |
483 | 483 | ||
484 | const localMention = `@(${actorNameAlphabet}+)` | 484 | const localMention = `@(${actorNameAlphabet}+)` |
485 | const remoteMention = `${localMention}@${CONFIG.WEBSERVER.HOST}` | 485 | const remoteMention = `${localMention}@${WEBSERVER.HOST}` |
486 | 486 | ||
487 | const mentionRegex = this.isOwned() | 487 | const mentionRegex = this.isOwned() |
488 | ? '(?:(?:' + remoteMention + ')|(?:' + localMention + '))' // Include local mentions? | 488 | ? '(?:(?:' + remoteMention + ')|(?:' + localMention + '))' // Include local mentions? |
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index dc10fb9a2..7915fc1f9 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts | |||
@@ -7,7 +7,7 @@ import { | |||
7 | ActivityUrlObject, | 7 | ActivityUrlObject, |
8 | VideoTorrentObject | 8 | VideoTorrentObject |
9 | } from '../../../shared/models/activitypub/objects' | 9 | } from '../../../shared/models/activitypub/objects' |
10 | import { CONFIG, MIMETYPES, THUMBNAILS_SIZE } from '../../initializers' | 10 | import { MIMETYPES, THUMBNAILS_SIZE, WEBSERVER } from '../../initializers' |
11 | import { VideoCaptionModel } from './video-caption' | 11 | import { VideoCaptionModel } from './video-caption' |
12 | import { | 12 | import { |
13 | getVideoCommentsActivityPubUrl, | 13 | getVideoCommentsActivityPubUrl, |
@@ -290,7 +290,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject { | |||
290 | type: 'Link', | 290 | type: 'Link', |
291 | mimeType: 'text/html', | 291 | mimeType: 'text/html', |
292 | mediaType: 'text/html', | 292 | mediaType: 'text/html', |
293 | href: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid | 293 | href: WEBSERVER.URL + '/videos/watch/' + video.uuid |
294 | }) | 294 | }) |
295 | 295 | ||
296 | const subtitleLanguage = [] | 296 | const subtitleLanguage = [] |
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts index 08e4d32c8..93f36a9d0 100644 --- a/server/models/video/video-playlist.ts +++ b/server/models/video/video-playlist.ts | |||
@@ -26,12 +26,12 @@ import { | |||
26 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 26 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
27 | import { | 27 | import { |
28 | ACTIVITY_PUB, | 28 | ACTIVITY_PUB, |
29 | CONFIG, | ||
30 | CONSTRAINTS_FIELDS, | 29 | CONSTRAINTS_FIELDS, |
31 | STATIC_PATHS, | 30 | STATIC_PATHS, |
32 | THUMBNAILS_SIZE, | 31 | THUMBNAILS_SIZE, |
33 | VIDEO_PLAYLIST_PRIVACIES, | 32 | VIDEO_PLAYLIST_PRIVACIES, |
34 | VIDEO_PLAYLIST_TYPES | 33 | VIDEO_PLAYLIST_TYPES, |
34 | WEBSERVER | ||
35 | } from '../../initializers' | 35 | } from '../../initializers' |
36 | import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model' | 36 | import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model' |
37 | import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account' | 37 | import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account' |
@@ -43,6 +43,7 @@ import { activityPubCollectionPagination } from '../../helpers/activitypub' | |||
43 | import { remove } from 'fs-extra' | 43 | import { remove } from 'fs-extra' |
44 | import { logger } from '../../helpers/logger' | 44 | import { logger } from '../../helpers/logger' |
45 | import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model' | 45 | import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model' |
46 | import { CONFIG } from '../../initializers/config' | ||
46 | 47 | ||
47 | enum ScopeNames { | 48 | enum ScopeNames { |
48 | AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', | 49 | AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', |
@@ -417,7 +418,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> { | |||
417 | } | 418 | } |
418 | 419 | ||
419 | getThumbnailUrl () { | 420 | getThumbnailUrl () { |
420 | return CONFIG.WEBSERVER.URL + STATIC_PATHS.THUMBNAILS + this.getThumbnailName() | 421 | return WEBSERVER.URL + STATIC_PATHS.THUMBNAILS + this.getThumbnailName() |
421 | } | 422 | } |
422 | 423 | ||
423 | getThumbnailStaticPath () { | 424 | getThumbnailStaticPath () { |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index b0d92b674..3b30e9e28 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -51,10 +51,9 @@ import { getServerActor } from '../../helpers/utils' | |||
51 | import { | 51 | import { |
52 | ACTIVITY_PUB, | 52 | ACTIVITY_PUB, |
53 | API_VERSION, | 53 | API_VERSION, |
54 | CONFIG, | ||
55 | CONSTRAINTS_FIELDS, | 54 | CONSTRAINTS_FIELDS, |
56 | HLS_STREAMING_PLAYLIST_DIRECTORY, | ||
57 | HLS_REDUNDANCY_DIRECTORY, | 55 | HLS_REDUNDANCY_DIRECTORY, |
56 | HLS_STREAMING_PLAYLIST_DIRECTORY, | ||
58 | PREVIEWS_SIZE, | 57 | PREVIEWS_SIZE, |
59 | REMOTE_SCHEME, | 58 | REMOTE_SCHEME, |
60 | STATIC_DOWNLOAD_PATHS, | 59 | STATIC_DOWNLOAD_PATHS, |
@@ -64,7 +63,8 @@ import { | |||
64 | VIDEO_LANGUAGES, | 63 | VIDEO_LANGUAGES, |
65 | VIDEO_LICENCES, | 64 | VIDEO_LICENCES, |
66 | VIDEO_PRIVACIES, | 65 | VIDEO_PRIVACIES, |
67 | VIDEO_STATES | 66 | VIDEO_STATES, |
67 | WEBSERVER | ||
68 | } from '../../initializers' | 68 | } from '../../initializers' |
69 | import { sendDeleteVideo } from '../../lib/activitypub/send' | 69 | import { sendDeleteVideo } from '../../lib/activitypub/send' |
70 | import { AccountModel } from '../account/account' | 70 | import { AccountModel } from '../account/account' |
@@ -77,12 +77,13 @@ import { | |||
77 | buildTrigramSearchIndex, | 77 | buildTrigramSearchIndex, |
78 | buildWhereIdOrUUID, | 78 | buildWhereIdOrUUID, |
79 | createSimilarityAttribute, | 79 | createSimilarityAttribute, |
80 | getVideoSort, isOutdated, | 80 | getVideoSort, |
81 | isOutdated, | ||
81 | throwIfNotValid | 82 | throwIfNotValid |
82 | } from '../utils' | 83 | } from '../utils' |
83 | import { TagModel } from './tag' | 84 | import { TagModel } from './tag' |
84 | import { VideoAbuseModel } from './video-abuse' | 85 | import { VideoAbuseModel } from './video-abuse' |
85 | import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel' | 86 | import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel' |
86 | import { VideoCommentModel } from './video-comment' | 87 | import { VideoCommentModel } from './video-comment' |
87 | import { VideoFileModel } from './video-file' | 88 | import { VideoFileModel } from './video-file' |
88 | import { VideoShareModel } from './video-share' | 89 | import { VideoShareModel } from './video-share' |
@@ -105,6 +106,7 @@ import { UserModel } from '../account/user' | |||
105 | import { VideoImportModel } from './video-import' | 106 | import { VideoImportModel } from './video-import' |
106 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' | 107 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' |
107 | import { VideoPlaylistElementModel } from './video-playlist-element' | 108 | import { VideoPlaylistElementModel } from './video-playlist-element' |
109 | import { CONFIG } from '../../initializers/config' | ||
108 | 110 | ||
109 | // FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation | 111 | // FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation |
110 | const indexes: Sequelize.DefineIndexesOptions[] = [ | 112 | const indexes: Sequelize.DefineIndexesOptions[] = [ |
@@ -1664,10 +1666,10 @@ export class VideoModel extends Model<VideoModel> { | |||
1664 | name: `${this.name} ${videoFile.resolution}p${videoFile.extname}`, | 1666 | name: `${this.name} ${videoFile.resolution}p${videoFile.extname}`, |
1665 | createdBy: 'PeerTube', | 1667 | createdBy: 'PeerTube', |
1666 | announceList: [ | 1668 | announceList: [ |
1667 | [ CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT + '/tracker/socket' ], | 1669 | [ WEBSERVER.WS + '://' + WEBSERVER.HOSTNAME + ':' + WEBSERVER.PORT + '/tracker/socket' ], |
1668 | [ CONFIG.WEBSERVER.URL + '/tracker/announce' ] | 1670 | [ WEBSERVER.URL + '/tracker/announce' ] |
1669 | ], | 1671 | ], |
1670 | urlList: [ CONFIG.WEBSERVER.URL + STATIC_PATHS.WEBSEED + this.getVideoFilename(videoFile) ] | 1672 | urlList: [ WEBSERVER.URL + STATIC_PATHS.WEBSEED + this.getVideoFilename(videoFile) ] |
1671 | } | 1673 | } |
1672 | 1674 | ||
1673 | const torrent = await createTorrentPromise(this.getVideoFilePath(videoFile), options) | 1675 | const torrent = await createTorrentPromise(this.getVideoFilePath(videoFile), options) |
@@ -1781,8 +1783,8 @@ export class VideoModel extends Model<VideoModel> { | |||
1781 | let baseUrlWs | 1783 | let baseUrlWs |
1782 | 1784 | ||
1783 | if (this.isOwned()) { | 1785 | if (this.isOwned()) { |
1784 | baseUrlHttp = CONFIG.WEBSERVER.URL | 1786 | baseUrlHttp = WEBSERVER.URL |
1785 | baseUrlWs = CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | 1787 | baseUrlWs = WEBSERVER.WS + '://' + WEBSERVER.HOSTNAME + ':' + WEBSERVER.PORT |
1786 | } else { | 1788 | } else { |
1787 | baseUrlHttp = REMOTE_SCHEME.HTTP + '://' + this.VideoChannel.Account.Actor.Server.host | 1789 | baseUrlHttp = REMOTE_SCHEME.HTTP + '://' + this.VideoChannel.Account.Actor.Server.host |
1788 | baseUrlWs = REMOTE_SCHEME.WS + '://' + this.VideoChannel.Account.Actor.Server.host | 1790 | baseUrlWs = REMOTE_SCHEME.WS + '://' + this.VideoChannel.Account.Actor.Server.host |