aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/video-channels.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts
index 79587b028..56a347b39 100644
--- a/server/middlewares/validators/video-channels.ts
+++ b/server/middlewares/validators/video-channels.ts
@@ -14,6 +14,7 @@ import { UserModel } from '../../models/account/user'
14import { VideoChannelModel } from '../../models/video/video-channel' 14import { VideoChannelModel } from '../../models/video/video-channel'
15import { areValidationErrors } from './utils' 15import { areValidationErrors } from './utils'
16import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' 16import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
17import { ActorModel } from '../../models/activitypub/actor'
17 18
18const listVideoAccountChannelsValidator = [ 19const listVideoAccountChannelsValidator = [
19 param('accountName').exists().withMessage('Should have a valid account name'), 20 param('accountName').exists().withMessage('Should have a valid account name'),
@@ -34,11 +35,19 @@ const videoChannelsAddValidator = [
34 body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), 35 body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'),
35 body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), 36 body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'),
36 37
37 (req: express.Request, res: express.Response, next: express.NextFunction) => { 38 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
38 logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body }) 39 logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body })
39 40
40 if (areValidationErrors(req, res)) return 41 if (areValidationErrors(req, res)) return
41 42
43 const actor = await ActorModel.loadLocalByName(req.body.name)
44 if (actor) {
45 res.status(409)
46 .send({ error: 'Another actor (account/channel) with this name on this instance already exists or has already existed.' })
47 .end()
48 return false
49 }
50
42 return next() 51 return next()
43 } 52 }
44] 53]