aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/csp.ts2
-rw-r--r--server/middlewares/validators/blocklist.ts5
-rw-r--r--server/middlewares/validators/follows.ts4
-rw-r--r--server/middlewares/validators/oembed.ts4
-rw-r--r--server/middlewares/validators/server.ts2
-rw-r--r--server/middlewares/validators/user-subscriptions.ts4
-rw-r--r--server/middlewares/validators/videos/video-imports.ts2
-rw-r--r--server/middlewares/validators/videos/videos.ts3
8 files changed, 13 insertions, 13 deletions
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 @@
1import * as helmet from 'helmet' 1import * as helmet from 'helmet'
2import { CONFIG } from '../initializers/constants' 2import { CONFIG } from '../initializers/config'
3 3
4const baseDirectives = Object.assign({}, 4const 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'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
5import { doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' 5import { doesAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
6import { UserModel } from '../../models/account/user'
7import { AccountBlocklistModel } from '../../models/account/account-blocklist' 6import { AccountBlocklistModel } from '../../models/account/account-blocklist'
8import { isHostValid } from '../../helpers/custom-validators/servers' 7import { isHostValid } from '../../helpers/custom-validators/servers'
9import { ServerBlocklistModel } from '../../models/server/server-blocklist' 8import { ServerBlocklistModel } from '../../models/server/server-blocklist'
10import { ServerModel } from '../../models/server/server' 9import { ServerModel } from '../../models/server/server'
11import { CONFIG } from '../../initializers'
12import { getServerActor } from '../../helpers/utils' 10import { getServerActor } from '../../helpers/utils'
11import { WEBSERVER } from '../../initializers/constants'
13 12
14const blockAccountValidator = [ 13const 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'
4import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' 4import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
5import { logger } from '../../helpers/logger' 5import { logger } from '../../helpers/logger'
6import { getServerActor } from '../../helpers/utils' 6import { getServerActor } from '../../helpers/utils'
7import { CONFIG, SERVER_ACTOR_NAME } from '../../initializers' 7import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers'
8import { ActorFollowModel } from '../../models/activitypub/actor-follow' 8import { ActorFollowModel } from '../../models/activitypub/actor-follow'
9import { areValidationErrors } from './utils' 9import { areValidationErrors } from './utils'
10import { ActorModel } from '../../models/activitypub/actor' 10import { 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'
5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
6import { doesVideoExist } from '../../helpers/custom-validators/videos' 6import { doesVideoExist } from '../../helpers/custom-validators/videos'
7import { logger } from '../../helpers/logger' 7import { logger } from '../../helpers/logger'
8import { CONFIG } from '../../initializers'
9import { areValidationErrors } from './utils' 8import { areValidationErrors } from './utils'
9import { WEBSERVER } from '../../initializers/constants'
10 10
11const urlShouldStartWith = CONFIG.WEBSERVER.SCHEME + '://' + join(CONFIG.WEBSERVER.HOST, 'videos', 'watch') + '/' 11const urlShouldStartWith = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch') + '/'
12const videoWatchRegex = new RegExp('([^/]+)$') 12const videoWatchRegex = new RegExp('([^/]+)$')
13const isURLOptions = { 13const 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'
7import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' 7import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
8import { Emailer } from '../../lib/emailer' 8import { Emailer } from '../../lib/emailer'
9import { Redis } from '../../lib/redis' 9import { Redis } from '../../lib/redis'
10import { CONFIG } from '../../initializers/constants' 10import { CONFIG } from '../../initializers/config'
11 11
12const serverGetValidator = [ 12const 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'
5import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
6import { ActorFollowModel } from '../../models/activitypub/actor-follow' 6import { ActorFollowModel } from '../../models/activitypub/actor-follow'
7import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' 7import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
8import { CONFIG } from '../../initializers'
9import { toArray } from '../../helpers/custom-validators/misc' 8import { toArray } from '../../helpers/custom-validators/misc'
9import { WEBSERVER } from '../../initializers/constants'
10 10
11const userSubscriptionAddValidator = [ 11const 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'
7import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports' 7import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports'
8import { cleanUpReqFiles } from '../../../helpers/express-utils' 8import { cleanUpReqFiles } from '../../../helpers/express-utils'
9import { doesVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos' 9import { doesVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos'
10import { CONFIG } from '../../../initializers/constants' 10import { CONFIG } from '../../../initializers/config'
11import { CONSTRAINTS_FIELDS } from '../../../initializers' 11import { CONSTRAINTS_FIELDS } from '../../../initializers'
12 12
13const videoImportAddValidator = getCommonVideoEditAttributes().concat([ 13const 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'
33import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils' 33import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils'
34import { logger } from '../../../helpers/logger' 34import { logger } from '../../../helpers/logger'
35import { CONFIG, CONSTRAINTS_FIELDS } from '../../../initializers' 35import { CONSTRAINTS_FIELDS } from '../../../initializers'
36import { authenticatePromiseIfNeeded } from '../../oauth' 36import { authenticatePromiseIfNeeded } from '../../oauth'
37import { areValidationErrors } from '../utils' 37import { areValidationErrors } from '../utils'
38import { cleanUpReqFiles } from '../../../helpers/express-utils' 38import { cleanUpReqFiles } from '../../../helpers/express-utils'
@@ -43,6 +43,7 @@ import { AccountModel } from '../../../models/account/account'
43import { VideoFetchType } from '../../../helpers/video' 43import { VideoFetchType } from '../../../helpers/video'
44import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search' 44import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search'
45import { getServerActor } from '../../../helpers/utils' 45import { getServerActor } from '../../../helpers/utils'
46import { CONFIG } from '../../../initializers/config'
46 47
47const videosAddValidator = getCommonVideoEditAttributes().concat([ 48const videosAddValidator = getCommonVideoEditAttributes().concat([
48 body('videofile') 49 body('videofile')