aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/activitypub/client.ts19
-rw-r--r--server/controllers/api/config.ts3
-rw-r--r--server/controllers/api/oauth-clients.ts2
-rw-r--r--server/controllers/api/server/logs.ts3
-rw-r--r--server/controllers/api/server/stats.ts3
-rw-r--r--server/controllers/api/users/index.ts7
-rw-r--r--server/controllers/api/users/me.ts3
-rw-r--r--server/controllers/api/users/my-subscriptions.ts4
-rw-r--r--server/controllers/api/video-channel.ts3
-rw-r--r--server/controllers/api/video-playlist.ts3
-rw-r--r--server/controllers/api/videos/captions.ts3
-rw-r--r--server/controllers/api/videos/import.ts5
-rw-r--r--server/controllers/api/videos/index.ts2
-rw-r--r--server/controllers/bots.ts16
-rw-r--r--server/controllers/feeds.ts11
-rw-r--r--server/controllers/services.ts6
-rw-r--r--server/controllers/static.ts7
-rw-r--r--server/controllers/tracker.ts3
18 files changed, 56 insertions, 47 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 @@
2import * as express from 'express' 2import * as express from 'express'
3import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' 3import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
4import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' 4import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
5import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' 5import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers'
6import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' 6import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send'
7import { audiencify, getAudience } from '../../lib/activitypub/audience' 7import { audiencify, getAudience } from '../../lib/activitypub/audience'
8import { buildCreateActivity } from '../../lib/activitypub/send/send-create' 8import { buildCreateActivity } from '../../lib/activitypub/send/send-create'
@@ -19,7 +19,6 @@ import { AccountModel } from '../../models/account/account'
19import { ActorModel } from '../../models/activitypub/actor' 19import { ActorModel } from '../../models/activitypub/actor'
20import { ActorFollowModel } from '../../models/activitypub/actor-follow' 20import { ActorFollowModel } from '../../models/activitypub/actor-follow'
21import { VideoModel } from '../../models/video/video' 21import { VideoModel } from '../../models/video/video'
22import { VideoChannelModel } from '../../models/video/video-channel'
23import { VideoCommentModel } from '../../models/video/video-comment' 22import { VideoCommentModel } from '../../models/video/video-comment'
24import { VideoShareModel } from '../../models/video/video-share' 23import { VideoShareModel } from '../../models/video/video-share'
25import { cacheRoute } from '../../middlewares/cache' 24import { cacheRoute } from '../../middlewares/cache'
@@ -35,11 +34,9 @@ import {
35import { VideoCaptionModel } from '../../models/video/video-caption' 34import { VideoCaptionModel } from '../../models/video/video-caption'
36import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' 35import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy'
37import { getServerActor } from '../../helpers/utils' 36import { getServerActor } from '../../helpers/utils'
38import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
39import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' 37import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike'
40import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' 38import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
41import { VideoPlaylistModel } from '../../models/video/video-playlist' 39import { VideoPlaylistModel } from '../../models/video/video-playlist'
42import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element'
43import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 40import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
44 41
45const activityPubClientRouter = express.Router() 42const 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) {
232async function videoAnnounceController (req: express.Request, res: express.Response) { 229async 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
306async function videoCommentController (req: express.Request, res: express.Response) { 303async 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
325async function videoRedundancyController (req: express.Request, res: express.Response) { 322async 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
372async function actorFollowers (req: express.Request, actor: ActorModel) { 369async 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
380async function actorPlaylists (req: express.Request, account: AccountModel) { 377async 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
388function videoRates (req: express.Request, rateType: VideoRateType, video: VideoModel, url: string) { 385function 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'
4import { About } from '../../../shared/models/server/about.model' 4import { About } from '../../../shared/models/server/about.model'
5import { CustomConfig } from '../../../shared/models/server/custom-config.model' 5import { CustomConfig } from '../../../shared/models/server/custom-config.model'
6import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' 6import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
7import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' 7import { CONSTRAINTS_FIELDS } from '../../initializers'
8import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' 8import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
9import { customConfigUpdateValidator } from '../../middlewares/validators/config' 9import { customConfigUpdateValidator } from '../../middlewares/validators/config'
10import { ClientHtml } from '../../lib/client-html' 10import { ClientHtml } from '../../lib/client-html'
@@ -14,6 +14,7 @@ import { getServerCommit } from '../../helpers/utils'
14import { Emailer } from '../../lib/emailer' 14import { Emailer } from '../../lib/emailer'
15import { isNumeric } from 'validator' 15import { isNumeric } from 'validator'
16import { objectConverter } from '../../helpers/core-utils' 16import { objectConverter } from '../../helpers/core-utils'
17import { CONFIG, reloadConfig } from '../../initializers/config'
17 18
18const packageJSON = require('../../../../package.json') 19const packageJSON = require('../../../../package.json')
19const configRouter = express.Router() 20const 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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { OAuthClientLocal } from '../../../shared' 2import { OAuthClientLocal } from '../../../shared'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { CONFIG } from '../../initializers' 4import { CONFIG } from '../../initializers/config'
5import { asyncMiddleware } from '../../middlewares' 5import { asyncMiddleware } from '../../middlewares'
6import { OAuthClientModel } from '../../models/oauth/oauth-client' 6import { 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'
3import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' 3import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
4import { mtimeSortFilesDesc } from '../../../../shared/utils/logs/logs' 4import { mtimeSortFilesDesc } from '../../../../shared/utils/logs/logs'
5import { readdir, readFile } from 'fs-extra' 5import { readdir, readFile } from 'fs-extra'
6import { CONFIG, MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers' 6import { MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers'
7import { join } from 'path' 7import { join } from 'path'
8import { getLogsValidator } from '../../../middlewares/validators/logs' 8import { getLogsValidator } from '../../../middlewares/validators/logs'
9import { LogLevel } from '../../../../shared/models/server/log-level.type' 9import { LogLevel } from '../../../../shared/models/server/log-level.type'
10import { CONFIG } from '../../../initializers/config'
10 11
11const logsRouter = express.Router() 12const 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'
6import { VideoModel } from '../../../models/video/video' 6import { VideoModel } from '../../../models/video/video'
7import { VideoCommentModel } from '../../../models/video/video-comment' 7import { VideoCommentModel } from '../../../models/video/video-comment'
8import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' 8import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy'
9import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' 9import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
10import { cacheRoute } from '../../../middlewares/cache' 10import { cacheRoute } from '../../../middlewares/cache'
11import { VideoFileModel } from '../../../models/video/video-file' 11import { VideoFileModel } from '../../../models/video/video-file'
12import { CONFIG } from '../../../initializers/config'
12 13
13const statsRouter = express.Router() 14const 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'
3import { UserCreate, UserRight, UserRole, UserUpdate } from '../../../../shared' 3import { UserCreate, UserRight, UserRole, UserUpdate } from '../../../../shared'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { getFormattedObjects } from '../../../helpers/utils' 5import { getFormattedObjects } from '../../../helpers/utils'
6import { CONFIG, RATES_LIMIT, sequelizeTypescript } from '../../../initializers' 6import { RATES_LIMIT, sequelizeTypescript, WEBSERVER } from '../../../initializers'
7import { Emailer } from '../../../lib/emailer' 7import { Emailer } from '../../../lib/emailer'
8import { Redis } from '../../../lib/redis' 8import { Redis } from '../../../lib/redis'
9import { createUserAccountAndChannelAndPlaylist } from '../../../lib/user' 9import { createUserAccountAndChannelAndPlaylist } from '../../../lib/user'
@@ -43,6 +43,7 @@ import { myVideosHistoryRouter } from './my-history'
43import { myNotificationsRouter } from './my-notifications' 43import { myNotificationsRouter } from './my-notifications'
44import { Notifier } from '../../../lib/notifier' 44import { Notifier } from '../../../lib/notifier'
45import { mySubscriptionsRouter } from './my-subscriptions' 45import { mySubscriptionsRouter } from './my-subscriptions'
46import { CONFIG } from '../../../initializers/config'
46 47
47const auditLogger = auditLoggerFactory('users') 48const 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
311async function sendVerifyUserEmail (user: UserModel) { 312async 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'
2import 'multer' 2import 'multer'
3import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' 3import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared'
4import { getFormattedObjects } from '../../../helpers/utils' 4import { getFormattedObjects } from '../../../helpers/utils'
5import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers' 5import { MIMETYPES, sequelizeTypescript } from '../../../initializers'
6import { sendUpdateActor } from '../../../lib/activitypub/send' 6import { sendUpdateActor } from '../../../lib/activitypub/send'
7import { 7import {
8 asyncMiddleware, 8 asyncMiddleware,
@@ -26,6 +26,7 @@ import { updateActorAvatarFile } from '../../../lib/avatar'
26import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' 26import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
27import { VideoImportModel } from '../../../models/video/video-import' 27import { VideoImportModel } from '../../../models/video/video-import'
28import { AccountModel } from '../../../models/account/account' 28import { AccountModel } from '../../../models/account/account'
29import { CONFIG } from '../../../initializers/config'
29 30
30const auditLogger = auditLoggerFactory('users-me') 31const 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 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'multer' 2import 'multer'
3import { getFormattedObjects } from '../../../helpers/utils' 3import { getFormattedObjects } from '../../../helpers/utils'
4import { CONFIG, sequelizeTypescript } from '../../../initializers' 4import { sequelizeTypescript, WEBSERVER } from '../../../initializers'
5import { 5import {
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'
23import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 23import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
24import { setAsyncActorKeys } from '../../lib/activitypub' 24import { setAsyncActorKeys } from '../../lib/activitypub'
25import { AccountModel } from '../../models/account/account' 25import { AccountModel } from '../../models/account/account'
26import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers' 26import { MIMETYPES, sequelizeTypescript } from '../../initializers'
27import { logger } from '../../helpers/logger' 27import { logger } from '../../helpers/logger'
28import { VideoModel } from '../../models/video/video' 28import { VideoModel } from '../../models/video/video'
29import { updateAvatarValidator } from '../../middlewares/validators/avatar' 29import { updateAvatarValidator } from '../../middlewares/validators/avatar'
@@ -33,6 +33,7 @@ import { resetSequelizeInstance } from '../../helpers/database-utils'
33import { JobQueue } from '../../lib/job-queue' 33import { JobQueue } from '../../lib/job-queue'
34import { VideoPlaylistModel } from '../../models/video/video-playlist' 34import { VideoPlaylistModel } from '../../models/video/video-playlist'
35import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' 35import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
36import { CONFIG } from '../../initializers/config'
36 37
37const auditLogger = auditLoggerFactory('channels') 38const auditLogger = auditLoggerFactory('channels')
38const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) 39const 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'
13import { videoPlaylistsSortValidator } from '../../middlewares/validators' 13import { videoPlaylistsSortValidator } from '../../middlewares/validators'
14import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 14import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
15import { CONFIG, MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers' 15import { MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers'
16import { logger } from '../../helpers/logger' 16import { logger } from '../../helpers/logger'
17import { resetSequelizeInstance } from '../../helpers/database-utils' 17import { resetSequelizeInstance } from '../../helpers/database-utils'
18import { VideoPlaylistModel } from '../../models/video/video-playlist' 18import { VideoPlaylistModel } from '../../models/video/video-playlist'
@@ -41,6 +41,7 @@ import { copy, pathExists } from 'fs-extra'
41import { AccountModel } from '../../models/account/account' 41import { AccountModel } from '../../models/account/account'
42import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' 42import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model'
43import { JobQueue } from '../../lib/job-queue' 43import { JobQueue } from '../../lib/job-queue'
44import { CONFIG } from '../../initializers/config'
44 45
45const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) 46const 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'
2import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' 2import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares'
3import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' 3import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators'
4import { createReqFiles } from '../../../helpers/express-utils' 4import { createReqFiles } from '../../../helpers/express-utils'
5import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers' 5import { MIMETYPES, sequelizeTypescript } from '../../../initializers'
6import { getFormattedObjects } from '../../../helpers/utils' 6import { getFormattedObjects } from '../../../helpers/utils'
7import { VideoCaptionModel } from '../../../models/video/video-caption' 7import { VideoCaptionModel } from '../../../models/video/video-caption'
8import { logger } from '../../../helpers/logger' 8import { logger } from '../../../helpers/logger'
9import { federateVideoIfNeeded } from '../../../lib/activitypub' 9import { federateVideoIfNeeded } from '../../../lib/activitypub'
10import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' 10import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
11import { CONFIG } from '../../../initializers/config'
11 12
12const reqVideoCaptionAdd = createReqFiles( 13const 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'
3import 'multer' 3import 'multer'
4import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' 4import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger'
5import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' 5import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'
6import { CONFIG, MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers' 6import { MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers'
7import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' 7import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl'
8import { createReqFiles } from '../../../helpers/express-utils' 8import { createReqFiles } from '../../../helpers/express-utils'
9import { logger } from '../../../helpers/logger' 9import { logger } from '../../../helpers/logger'
@@ -22,8 +22,9 @@ import { UserModel } from '../../../models/account/user'
22import * as Bluebird from 'bluebird' 22import * as Bluebird from 'bluebird'
23import * as parseTorrent from 'parse-torrent' 23import * as parseTorrent from 'parse-torrent'
24import { getSecureTorrentName } from '../../../helpers/utils' 24import { getSecureTorrentName } from '../../../helpers/utils'
25import { readFile, move } from 'fs-extra' 25import { move, readFile } from 'fs-extra'
26import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' 26import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
27import { CONFIG } from '../../../initializers/config'
27 28
28const auditLogger = auditLoggerFactory('video-imports') 29const auditLogger = auditLoggerFactory('video-imports')
29const videoImportsRouter = express.Router() 30const 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 '../../../
8import { getFormattedObjects, getServerActor } from '../../../helpers/utils' 8import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
9import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' 9import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
10import { 10import {
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'
61import { watchingRouter } from './watching' 60import { watchingRouter } from './watching'
62import { Notifier } from '../../../lib/notifier' 61import { Notifier } from '../../../lib/notifier'
63import { sendView } from '../../../lib/activitypub/send/send-view' 62import { sendView } from '../../../lib/activitypub/send/send-view'
63import { CONFIG } from '../../../initializers/config'
64 64
65const auditLogger = auditLoggerFactory('videos') 65const auditLogger = auditLoggerFactory('videos')
66const videosRouter = express.Router() 66const 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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { asyncMiddleware } from '../middlewares' 2import { asyncMiddleware } from '../middlewares'
3import { CONFIG, ROUTE_CACHE_LIFETIME } from '../initializers' 3import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers'
4import * as sitemapModule from 'sitemap' 4import * as sitemapModule from 'sitemap'
5import { logger } from '../helpers/logger' 5import { logger } from '../helpers/logger'
6import { VideoModel } from '../models/video/video' 6import { 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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { CONFIG, FEEDS, ROUTE_CACHE_LIFETIME } from '../initializers/constants' 2import { FEEDS, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
3import { THUMBNAILS_SIZE } from '../initializers' 3import { THUMBNAILS_SIZE } from '../initializers'
4import { 4import {
5 asyncMiddleware, 5 asyncMiddleware,
@@ -14,6 +14,7 @@ import * as Feed from 'pfeed'
14import { cacheRoute } from '../middlewares/cache' 14import { cacheRoute } from '../middlewares/cache'
15import { VideoCommentModel } from '../models/video/video-comment' 15import { VideoCommentModel } from '../models/video/video-comment'
16import { buildNSFWFilter } from '../helpers/express-utils' 16import { buildNSFWFilter } from '../helpers/express-utils'
17import { CONFIG } from '../initializers/config'
17 18
18const feedsRouter = express.Router() 19const 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
152function initFeed (name: string, description: string) { 153function 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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { CONFIG, EMBED_SIZE, PREVIEWS_SIZE } from '../initializers' 2import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER } from '../initializers'
3import { asyncMiddleware, oembedValidator } from '../middlewares' 3import { asyncMiddleware, oembedValidator } from '../middlewares'
4import { accountNameWithHostGetValidator } from '../middlewares/validators' 4import { accountNameWithHostGetValidator } from '../middlewares/validators'
5import { VideoModel } from '../models/video/video' 5import { CONFIG } from '../initializers/config'
6 6
7const servicesRouter = express.Router() 7const servicesRouter = express.Router()
8 8
@@ -25,7 +25,7 @@ export {
25 25
26function generateOEmbed (req: express.Request, res: express.Response) { 26function 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 @@
1import * as cors from 'cors' 1import * as cors from 'cors'
2import * as express from 'express' 2import * as express from 'express'
3import { 3import {
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'
11import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' 11import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache'
12import { cacheRoute } from '../middlewares/cache' 12import { cacheRoute } from '../middlewares/cache'
@@ -17,6 +17,7 @@ import { VideoCommentModel } from '../models/video/video-comment'
17import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo' 17import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo'
18import { join } from 'path' 18import { join } from 'path'
19import { root } from '../helpers/core-utils' 19import { root } from '../helpers/core-utils'
20import { CONFIG } from '../initializers/config'
20 21
21const packageJSON = require('../../../package.json') 22const packageJSON = require('../../../package.json')
22const staticRouter = express.Router() 23const 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'
4import * as bitTorrentTracker from 'bittorrent-tracker' 4import * as bitTorrentTracker from 'bittorrent-tracker'
5import * as proxyAddr from 'proxy-addr' 5import * as proxyAddr from 'proxy-addr'
6import { Server as WebSocketServer } from 'ws' 6import { Server as WebSocketServer } from 'ws'
7import { CONFIG, TRACKER_RATE_LIMITS } from '../initializers/constants' 7import { TRACKER_RATE_LIMITS } from '../initializers/constants'
8import { VideoFileModel } from '../models/video/video-file' 8import { VideoFileModel } from '../models/video/video-file'
9import { parse } from 'url' 9import { parse } from 'url'
10import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' 10import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
11import { CONFIG } from '../initializers/config'
11 12
12const TrackerServer = bitTorrentTracker.Server 13const TrackerServer = bitTorrentTracker.Server
13 14