From 6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Apr 2019 11:33:44 +0200 Subject: Move config in its own file --- server/controllers/activitypub/client.ts | 19 ++++++++----------- server/controllers/api/config.ts | 3 ++- server/controllers/api/oauth-clients.ts | 2 +- server/controllers/api/server/logs.ts | 3 ++- server/controllers/api/server/stats.ts | 3 ++- server/controllers/api/users/index.ts | 7 ++++--- server/controllers/api/users/me.ts | 3 ++- server/controllers/api/users/my-subscriptions.ts | 4 ++-- server/controllers/api/video-channel.ts | 3 ++- server/controllers/api/video-playlist.ts | 3 ++- server/controllers/api/videos/captions.ts | 3 ++- server/controllers/api/videos/import.ts | 5 +++-- server/controllers/api/videos/index.ts | 2 +- server/controllers/bots.ts | 16 ++++++++-------- server/controllers/feeds.ts | 11 ++++++----- server/controllers/services.ts | 6 +++--- server/controllers/static.ts | 7 ++++--- server/controllers/tracker.ts | 3 ++- 18 files changed, 56 insertions(+), 47 deletions(-) (limited to 'server/controllers') 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 @@ import * as express from 'express' import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' -import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../initializers' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers' import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' import { audiencify, getAudience } from '../../lib/activitypub/audience' import { buildCreateActivity } from '../../lib/activitypub/send/send-create' @@ -19,7 +19,6 @@ import { AccountModel } from '../../models/account/account' import { ActorModel } from '../../models/activitypub/actor' import { ActorFollowModel } from '../../models/activitypub/actor-follow' import { VideoModel } from '../../models/video/video' -import { VideoChannelModel } from '../../models/video/video-channel' import { VideoCommentModel } from '../../models/video/video-comment' import { VideoShareModel } from '../../models/video/video-share' import { cacheRoute } from '../../middlewares/cache' @@ -35,11 +34,9 @@ import { import { VideoCaptionModel } from '../../models/video/video-caption' import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' import { getServerActor } from '../../helpers/utils' -import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' import { VideoPlaylistModel } from '../../models/video/video-playlist' -import { VideoPlaylistElementModel } from '../../models/video/video-playlist-element' import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' const activityPubClientRouter = express.Router() @@ -213,7 +210,7 @@ async function videoController (req: express.Request, res: express.Response) { // We need more attributes const video = await VideoModel.loadForGetAPI(res.locals.video.id) - if (video.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(video.url) + if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url) // We need captions to render AP object video.VideoCaptions = await VideoCaptionModel.listVideoCaptions(video.id) @@ -232,7 +229,7 @@ async function videoController (req: express.Request, res: express.Response) { async function videoAnnounceController (req: express.Request, res: express.Response) { const share = res.locals.videoShare - if (share.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(share.url) + if (share.url.startsWith(WEBSERVER.URL) === false) return res.redirect(share.url) const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.video, undefined) @@ -306,7 +303,7 @@ async function videoChannelFollowingController (req: express.Request, res: expre async function videoCommentController (req: express.Request, res: express.Response) { const videoComment = res.locals.videoComment - if (videoComment.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoComment.url) + if (videoComment.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoComment.url) const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined) const isPublic = true // Comments are always public @@ -324,7 +321,7 @@ async function videoCommentController (req: express.Request, res: express.Respon async function videoRedundancyController (req: express.Request, res: express.Response) { const videoRedundancy = res.locals.videoRedundancy - if (videoRedundancy.url.startsWith(CONFIG.WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url) + if (videoRedundancy.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url) const serverActor = await getServerActor() @@ -366,7 +363,7 @@ async function actorFollowing (req: express.Request, actor: ActorModel) { return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count) } - return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page) + return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) } async function actorFollowers (req: express.Request, actor: ActorModel) { @@ -374,7 +371,7 @@ async function actorFollowers (req: express.Request, actor: ActorModel) { return ActorFollowModel.listAcceptedFollowerUrlsForAP([ actor.id ], undefined, start, count) } - return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page) + return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) } async function actorPlaylists (req: express.Request, account: AccountModel) { @@ -382,7 +379,7 @@ async function actorPlaylists (req: express.Request, account: AccountModel) { return VideoPlaylistModel.listPublicUrlsOfForAP(account.id, start, count) } - return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.path, handler, req.query.page) + return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) } 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' import { About } from '../../../shared/models/server/about.model' import { CustomConfig } from '../../../shared/models/server/custom-config.model' import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' -import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' import { customConfigUpdateValidator } from '../../middlewares/validators/config' import { ClientHtml } from '../../lib/client-html' @@ -14,6 +14,7 @@ import { getServerCommit } from '../../helpers/utils' import { Emailer } from '../../lib/emailer' import { isNumeric } from 'validator' import { objectConverter } from '../../helpers/core-utils' +import { CONFIG, reloadConfig } from '../../initializers/config' const packageJSON = require('../../../../package.json') 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 @@ import * as express from 'express' import { OAuthClientLocal } from '../../../shared' import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers' +import { CONFIG } from '../../initializers/config' import { asyncMiddleware } from '../../middlewares' import { OAuthClientModel } from '../../models/oauth/oauth-client' 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' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' import { mtimeSortFilesDesc } from '../../../../shared/utils/logs/logs' import { readdir, readFile } from 'fs-extra' -import { CONFIG, MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers' +import { MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers' import { join } from 'path' import { getLogsValidator } from '../../../middlewares/validators/logs' import { LogLevel } from '../../../../shared/models/server/log-level.type' +import { CONFIG } from '../../../initializers/config' const logsRouter = express.Router() 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' import { VideoModel } from '../../../models/video/video' import { VideoCommentModel } from '../../../models/video/video-comment' import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' -import { CONFIG, ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' +import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' import { cacheRoute } from '../../../middlewares/cache' import { VideoFileModel } from '../../../models/video/video-file' +import { CONFIG } from '../../../initializers/config' const statsRouter = express.Router() 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' import { UserCreate, UserRight, UserRole, UserUpdate } from '../../../../shared' import { logger } from '../../../helpers/logger' import { getFormattedObjects } from '../../../helpers/utils' -import { CONFIG, RATES_LIMIT, sequelizeTypescript } from '../../../initializers' +import { RATES_LIMIT, sequelizeTypescript, WEBSERVER } from '../../../initializers' import { Emailer } from '../../../lib/emailer' import { Redis } from '../../../lib/redis' import { createUserAccountAndChannelAndPlaylist } from '../../../lib/user' @@ -43,6 +43,7 @@ import { myVideosHistoryRouter } from './my-history' import { myNotificationsRouter } from './my-notifications' import { Notifier } from '../../../lib/notifier' import { mySubscriptionsRouter } from './my-subscriptions' +import { CONFIG } from '../../../initializers/config' const auditLogger = auditLoggerFactory('users') @@ -293,7 +294,7 @@ async function askResetUserPassword (req: express.Request, res: express.Response const user = res.locals.user const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id) - const url = CONFIG.WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString + const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString await Emailer.Instance.addPasswordResetEmailJob(user.email, url) return res.status(204).end() @@ -310,7 +311,7 @@ async function resetUserPassword (req: express.Request, res: express.Response) { async function sendVerifyUserEmail (user: UserModel) { const verificationString = await Redis.Instance.setVerifyEmailVerificationString(user.id) - const url = CONFIG.WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString + const url = WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString await Emailer.Instance.addVerifyEmailJob(user.email, url) return } 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' import 'multer' import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' import { getFormattedObjects } from '../../../helpers/utils' -import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers' +import { MIMETYPES, sequelizeTypescript } from '../../../initializers' import { sendUpdateActor } from '../../../lib/activitypub/send' import { asyncMiddleware, @@ -26,6 +26,7 @@ import { updateActorAvatarFile } from '../../../lib/avatar' import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' import { VideoImportModel } from '../../../models/video/video-import' import { AccountModel } from '../../../models/account/account' +import { CONFIG } from '../../../initializers/config' const auditLogger = auditLoggerFactory('users-me') 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 @@ import * as express from 'express' import 'multer' import { getFormattedObjects } from '../../../helpers/utils' -import { CONFIG, sequelizeTypescript } from '../../../initializers' +import { sequelizeTypescript, WEBSERVER } from '../../../initializers' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -80,7 +80,7 @@ async function areSubscriptionsExist (req: express.Request, res: express.Respons const handles = uris.map(u => { let [ name, host ] = u.split('@') - if (host === CONFIG.WEBSERVER.HOST) host = null + if (host === WEBSERVER.HOST) host = null return { name, host, uri: u } }) 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' import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' import { setAsyncActorKeys } from '../../lib/activitypub' import { AccountModel } from '../../models/account/account' -import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers' +import { MIMETYPES, sequelizeTypescript } from '../../initializers' import { logger } from '../../helpers/logger' import { VideoModel } from '../../models/video/video' import { updateAvatarValidator } from '../../middlewares/validators/avatar' @@ -33,6 +33,7 @@ import { resetSequelizeInstance } from '../../helpers/database-utils' import { JobQueue } from '../../lib/job-queue' import { VideoPlaylistModel } from '../../models/video/video-playlist' import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' +import { CONFIG } from '../../initializers/config' const auditLogger = auditLoggerFactory('channels') 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 { } from '../../middlewares' import { videoPlaylistsSortValidator } from '../../middlewares/validators' import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' -import { CONFIG, MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers' +import { MIMETYPES, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_PLAYLIST_PRIVACIES } from '../../initializers' import { logger } from '../../helpers/logger' import { resetSequelizeInstance } from '../../helpers/database-utils' import { VideoPlaylistModel } from '../../models/video/video-playlist' @@ -41,6 +41,7 @@ import { copy, pathExists } from 'fs-extra' import { AccountModel } from '../../models/account/account' import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' import { JobQueue } from '../../lib/job-queue' +import { CONFIG } from '../../initializers/config' const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) 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' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' import { addVideoCaptionValidator, deleteVideoCaptionValidator, listVideoCaptionsValidator } from '../../../middlewares/validators' import { createReqFiles } from '../../../helpers/express-utils' -import { CONFIG, MIMETYPES, sequelizeTypescript } from '../../../initializers' +import { MIMETYPES, sequelizeTypescript } from '../../../initializers' import { getFormattedObjects } from '../../../helpers/utils' import { VideoCaptionModel } from '../../../models/video/video-caption' import { logger } from '../../../helpers/logger' import { federateVideoIfNeeded } from '../../../lib/activitypub' import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' +import { CONFIG } from '../../../initializers/config' const reqVideoCaptionAdd = createReqFiles( [ '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' import 'multer' import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' -import { CONFIG, MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers' +import { MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers' import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' import { createReqFiles } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' @@ -22,8 +22,9 @@ import { UserModel } from '../../../models/account/user' import * as Bluebird from 'bluebird' import * as parseTorrent from 'parse-torrent' import { getSecureTorrentName } from '../../../helpers/utils' -import { readFile, move } from 'fs-extra' +import { move, readFile } from 'fs-extra' import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' +import { CONFIG } from '../../../initializers/config' const auditLogger = auditLoggerFactory('video-imports') 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 '../../../ import { getFormattedObjects, getServerActor } from '../../../helpers/utils' import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' import { - CONFIG, MIMETYPES, PREVIEWS_SIZE, sequelizeTypescript, @@ -61,6 +60,7 @@ import { move } from 'fs-extra' import { watchingRouter } from './watching' import { Notifier } from '../../../lib/notifier' import { sendView } from '../../../lib/activitypub/send/send-view' +import { CONFIG } from '../../../initializers/config' const auditLogger = auditLoggerFactory('videos') 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 @@ import * as express from 'express' import { asyncMiddleware } from '../middlewares' -import { CONFIG, ROUTE_CACHE_LIFETIME } from '../initializers' +import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers' import * as sitemapModule from 'sitemap' import { logger } from '../helpers/logger' import { VideoModel } from '../models/video/video' @@ -35,7 +35,7 @@ async function getSitemap (req: express.Request, res: express.Response) { urls = urls.concat(await getSitemapAccountUrls()) const sitemap = sitemapModule.createSitemap({ - hostname: CONFIG.WEBSERVER.URL, + hostname: WEBSERVER.URL, urls: urls }) @@ -54,7 +54,7 @@ async function getSitemapVideoChannelUrls () { const rows = await VideoChannelModel.listLocalsForSitemap('createdAt') return rows.map(channel => ({ - url: CONFIG.WEBSERVER.URL + '/video-channels/' + channel.Actor.preferredUsername + url: WEBSERVER.URL + '/video-channels/' + channel.Actor.preferredUsername })) } @@ -62,7 +62,7 @@ async function getSitemapAccountUrls () { const rows = await AccountModel.listLocalsForSitemap('createdAt') return rows.map(channel => ({ - url: CONFIG.WEBSERVER.URL + '/accounts/' + channel.Actor.preferredUsername + url: WEBSERVER.URL + '/accounts/' + channel.Actor.preferredUsername })) } @@ -78,14 +78,14 @@ async function getSitemapLocalVideoUrls () { }) return resultList.data.map(v => ({ - url: CONFIG.WEBSERVER.URL + '/videos/watch/' + v.uuid, + url: WEBSERVER.URL + '/videos/watch/' + v.uuid, video: [ { title: v.name, // Sitemap description should be < 2000 characters description: truncate(v.description || v.name, { length: 2000, omission: '...' }), - player_loc: CONFIG.WEBSERVER.URL + '/videos/embed/' + v.uuid, - thumbnail_loc: CONFIG.WEBSERVER.URL + v.getThumbnailStaticPath() + player_loc: WEBSERVER.URL + '/videos/embed/' + v.uuid, + thumbnail_loc: WEBSERVER.URL + v.getThumbnailStaticPath() } ] })) @@ -97,5 +97,5 @@ function getSitemapBasicUrls () { '/videos/local' ] - return paths.map(p => ({ url: CONFIG.WEBSERVER.URL + p })) + return paths.map(p => ({ url: WEBSERVER.URL + p })) } 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 @@ import * as express from 'express' -import { CONFIG, FEEDS, ROUTE_CACHE_LIFETIME } from '../initializers/constants' +import { FEEDS, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' import { THUMBNAILS_SIZE } from '../initializers' import { asyncMiddleware, @@ -14,6 +14,7 @@ import * as Feed from 'pfeed' import { cacheRoute } from '../middlewares/cache' import { VideoCommentModel } from '../models/video/video-comment' import { buildNSFWFilter } from '../helpers/express-utils' +import { CONFIG } from '../initializers/config' const feedsRouter = express.Router() @@ -54,7 +55,7 @@ async function generateVideoCommentsFeed (req: express.Request, res: express.Res // Adding video items to the feed, one at a time comments.forEach(comment => { - const link = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath() + const link = WEBSERVER.URL + comment.getCommentStaticPath() feed.addItem({ title: `${comment.Video.name} - ${comment.Account.getDisplayName()}`, @@ -122,7 +123,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) { feed.addItem({ title: video.name, id: video.url, - link: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid, + link: WEBSERVER.URL + '/videos/watch/' + video.uuid, description: video.getTruncatedDescription(), content: video.description, author: [ @@ -137,7 +138,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) { torrent: torrents, thumbnail: [ { - url: CONFIG.WEBSERVER.URL + video.getThumbnailStaticPath(), + url: WEBSERVER.URL + video.getThumbnailStaticPath(), height: THUMBNAILS_SIZE.height, width: THUMBNAILS_SIZE.width } @@ -150,7 +151,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) { } function initFeed (name: string, description: string) { - const webserverUrl = CONFIG.WEBSERVER.URL + const webserverUrl = WEBSERVER.URL return new Feed({ 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 @@ import * as express from 'express' -import { CONFIG, EMBED_SIZE, PREVIEWS_SIZE } from '../initializers' +import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER } from '../initializers' import { asyncMiddleware, oembedValidator } from '../middlewares' import { accountNameWithHostGetValidator } from '../middlewares/validators' -import { VideoModel } from '../models/video/video' +import { CONFIG } from '../initializers/config' const servicesRouter = express.Router() @@ -25,7 +25,7 @@ export { function generateOEmbed (req: express.Request, res: express.Response) { const video = res.locals.video - const webserverUrl = CONFIG.WEBSERVER.URL + const webserverUrl = WEBSERVER.URL const maxHeight = parseInt(req.query.maxheight, 10) const maxWidth = parseInt(req.query.maxwidth, 10) 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 @@ import * as cors from 'cors' import * as express from 'express' import { - CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, ROUTE_CACHE_LIFETIME, STATIC_DOWNLOAD_PATHS, STATIC_MAX_AGE, - STATIC_PATHS + STATIC_PATHS, + WEBSERVER } from '../initializers' import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' import { cacheRoute } from '../middlewares/cache' @@ -17,6 +17,7 @@ import { VideoCommentModel } from '../models/video/video-comment' import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo' import { join } from 'path' import { root } from '../helpers/core-utils' +import { CONFIG } from '../initializers/config' const packageJSON = require('../../../package.json') const staticRouter = express.Router() @@ -121,7 +122,7 @@ staticRouter.use('/.well-known/nodeinfo', links: [ { rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', - href: CONFIG.WEBSERVER.URL + '/nodeinfo/2.0.json' + href: WEBSERVER.URL + '/nodeinfo/2.0.json' } ] }) 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' import * as bitTorrentTracker from 'bittorrent-tracker' import * as proxyAddr from 'proxy-addr' import { Server as WebSocketServer } from 'ws' -import { CONFIG, TRACKER_RATE_LIMITS } from '../initializers/constants' +import { TRACKER_RATE_LIMITS } from '../initializers/constants' import { VideoFileModel } from '../models/video/video-file' import { parse } from 'url' import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' +import { CONFIG } from '../initializers/config' const TrackerServer = bitTorrentTracker.Server -- cgit v1.2.3