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/middlewares/csp.ts | 2 +- server/middlewares/validators/blocklist.ts | 5 ++--- server/middlewares/validators/follows.ts | 4 ++-- server/middlewares/validators/oembed.ts | 4 ++-- server/middlewares/validators/server.ts | 2 +- server/middlewares/validators/user-subscriptions.ts | 4 ++-- server/middlewares/validators/videos/video-imports.ts | 2 +- server/middlewares/validators/videos/videos.ts | 3 ++- 8 files changed, 13 insertions(+), 13 deletions(-) (limited to 'server/middlewares') 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 @@ import * as helmet from 'helmet' -import { CONFIG } from '../initializers/constants' +import { CONFIG } from '../initializers/config' const baseDirectives = Object.assign({}, { 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' import { logger } from '../../helpers/logger' import { areValidationErrors } from './utils' import { doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' -import { UserModel } from '../../models/account/user' import { AccountBlocklistModel } from '../../models/account/account-blocklist' import { isHostValid } from '../../helpers/custom-validators/servers' import { ServerBlocklistModel } from '../../models/server/server-blocklist' import { ServerModel } from '../../models/server/server' -import { CONFIG } from '../../initializers' import { getServerActor } from '../../helpers/utils' +import { WEBSERVER } from '../../initializers/constants' const blockAccountValidator = [ body('accountName').exists().withMessage('Should have an account name with host'), @@ -79,7 +78,7 @@ const blockServerValidator = [ const host: string = req.body.host - if (host === CONFIG.WEBSERVER.HOST) { + if (host === WEBSERVER.HOST) { return res.status(409) .send({ error: 'You cannot block your own server.' }) .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' import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' import { logger } from '../../helpers/logger' import { getServerActor } from '../../helpers/utils' -import { CONFIG, SERVER_ACTOR_NAME } from '../../initializers' +import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers' import { ActorFollowModel } from '../../models/activitypub/actor-follow' import { areValidationErrors } from './utils' import { ActorModel } from '../../models/activitypub/actor' @@ -16,7 +16,7 @@ const followValidator = [ (req: express.Request, res: express.Response, next: express.NextFunction) => { // Force https if the administrator wants to make friends - if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') { + if (isTestInstance() === false && WEBSERVER.SCHEME === 'http') { return res.status(500) .json({ 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' import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' import { doesVideoExist } from '../../helpers/custom-validators/videos' import { logger } from '../../helpers/logger' -import { CONFIG } from '../../initializers' import { areValidationErrors } from './utils' +import { WEBSERVER } from '../../initializers/constants' -const urlShouldStartWith = CONFIG.WEBSERVER.SCHEME + '://' + join(CONFIG.WEBSERVER.HOST, 'videos', 'watch') + '/' +const urlShouldStartWith = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch') + '/' const videoWatchRegex = new RegExp('([^/]+)$') const isURLOptions = { 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' import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' import { Emailer } from '../../lib/emailer' import { Redis } from '../../lib/redis' -import { CONFIG } from '../../initializers/constants' +import { CONFIG } from '../../initializers/config' const serverGetValidator = [ 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' import { areValidationErrors } from './utils' import { ActorFollowModel } from '../../models/activitypub/actor-follow' import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' -import { CONFIG } from '../../initializers' import { toArray } from '../../helpers/custom-validators/misc' +import { WEBSERVER } from '../../initializers/constants' const userSubscriptionAddValidator = [ body('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'), @@ -43,7 +43,7 @@ const userSubscriptionGetValidator = [ if (areValidationErrors(req, res)) return let [ name, host ] = req.params.uri.split('@') - if (host === CONFIG.WEBSERVER.HOST) host = null + if (host === WEBSERVER.HOST) host = null const user = res.locals.oauth.token.User 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' import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports' import { cleanUpReqFiles } from '../../../helpers/express-utils' import { doesVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos' -import { CONFIG } from '../../../initializers/constants' +import { CONFIG } from '../../../initializers/config' import { CONSTRAINTS_FIELDS } from '../../../initializers' 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 { } from '../../../helpers/custom-validators/videos' import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils' import { logger } from '../../../helpers/logger' -import { CONFIG, CONSTRAINTS_FIELDS } from '../../../initializers' +import { CONSTRAINTS_FIELDS } from '../../../initializers' import { authenticatePromiseIfNeeded } from '../../oauth' import { areValidationErrors } from '../utils' import { cleanUpReqFiles } from '../../../helpers/express-utils' @@ -43,6 +43,7 @@ import { AccountModel } from '../../../models/account/account' import { VideoFetchType } from '../../../helpers/video' import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search' import { getServerActor } from '../../../helpers/utils' +import { CONFIG } from '../../../initializers/config' const videosAddValidator = getCommonVideoEditAttributes().concat([ body('videofile') -- cgit v1.2.3