From 608624252466acf9f1d9ee1c1170bd4fe4d18d18 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Nov 2017 11:00:25 +0100 Subject: Rename Pod -> Server --- server/middlewares/validators/index.ts | 2 +- server/middlewares/validators/pods.ts | 32 ------------------------- server/middlewares/validators/servers.ts | 32 +++++++++++++++++++++++++ server/middlewares/validators/video-channels.ts | 4 ++-- server/middlewares/validators/videos.ts | 4 ++-- 5 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 server/middlewares/validators/pods.ts create mode 100644 server/middlewares/validators/servers.ts (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/index.ts b/server/middlewares/validators/index.ts index 92a4bad28..3f5afe5b3 100644 --- a/server/middlewares/validators/index.ts +++ b/server/middlewares/validators/index.ts @@ -2,7 +2,7 @@ export * from './account' export * from './oembed' export * from './activitypub' export * from './pagination' -export * from './pods' +export * from './servers' export * from './sort' export * from './users' export * from './videos' diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts deleted file mode 100644 index e17369a6f..000000000 --- a/server/middlewares/validators/pods.ts +++ /dev/null @@ -1,32 +0,0 @@ -import * as express from 'express' -import { body } from 'express-validator/check' -import { isEachUniqueHostValid } from '../../helpers/custom-validators/pods' -import { isTestInstance } from '../../helpers/core-utils' -import { CONFIG } from '../../initializers/constants' -import { logger } from '../../helpers/logger' -import { checkErrors } from './utils' - -const followValidator = [ - body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'), - - (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') { - return res.status(400) - .json({ - error: 'Cannot follow non HTTPS web server.' - }) - .end() - } - - logger.debug('Checking follow parameters', { parameters: req.body }) - - checkErrors(req, res, next) - } -] - -// --------------------------------------------------------------------------- - -export { - followValidator -} diff --git a/server/middlewares/validators/servers.ts b/server/middlewares/validators/servers.ts new file mode 100644 index 000000000..95b69b789 --- /dev/null +++ b/server/middlewares/validators/servers.ts @@ -0,0 +1,32 @@ +import * as express from 'express' +import { body } from 'express-validator/check' +import { isEachUniqueHostValid } from '../../helpers/custom-validators/servers' +import { isTestInstance } from '../../helpers/core-utils' +import { CONFIG } from '../../initializers/constants' +import { logger } from '../../helpers/logger' +import { checkErrors } from './utils' + +const followValidator = [ + body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'), + + (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') { + return res.status(400) + .json({ + error: 'Cannot follow non HTTPS web server.' + }) + .end() + } + + logger.debug('Checking follow parameters', { parameters: req.body }) + + checkErrors(req, res, next) + } +] + +// --------------------------------------------------------------------------- + +export { + followValidator +} diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts index 53416a857..f0ead24e3 100644 --- a/server/middlewares/validators/video-channels.ts +++ b/server/middlewares/validators/video-channels.ts @@ -50,7 +50,7 @@ const videoChannelsUpdateValidator = [ // We need to make additional checks if (res.locals.videoChannel.isOwned() === false) { return res.status(403) - .json({ error: 'Cannot update video channel of another pod' }) + .json({ error: 'Cannot update video channel of another server' }) .end() } @@ -113,7 +113,7 @@ function checkUserCanDeleteVideoChannel (res: express.Response, callback: () => // Retrieve the user who did the request if (res.locals.videoChannel.isOwned() === false) { return res.status(403) - .json({ error: 'Cannot remove video channel of another pod.' }) + .json({ error: 'Cannot remove video channel of another server.' }) .end() } diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index 10b426df3..158b475e3 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts @@ -127,7 +127,7 @@ const videosUpdateValidator = [ // We need to make additional checks if (video.isOwned() === false) { return res.status(403) - .json({ error: 'Cannot update video of another pod' }) + .json({ error: 'Cannot update video of another server' }) .end() } @@ -250,7 +250,7 @@ function checkUserCanDeleteVideo (userId: number, res: express.Response, callbac // Retrieve the user who did the request if (res.locals.video.isOwned() === false) { return res.status(403) - .json({ error: 'Cannot remove video of another pod, blacklist it' }) + .json({ error: 'Cannot remove video of another server, blacklist it' }) .end() } -- cgit v1.2.3