diff options
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/activitypub.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/video-channels.ts | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index 12d5c22c5..d7f59be8c 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts | |||
@@ -18,7 +18,7 @@ async function checkSignature (req: Request, res: Response, next: NextFunction) | |||
18 | try { | 18 | try { |
19 | actor = await getOrCreateActorAndServerAndModel(creator) | 19 | actor = await getOrCreateActorAndServerAndModel(creator) |
20 | } catch (err) { | 20 | } catch (err) { |
21 | logger.error('Cannot create remote actor and check signature.', { err }) | 21 | logger.warn('Cannot create remote actor %s and check signature.', creator, { err }) |
22 | return res.sendStatus(403) | 22 | return res.sendStatus(403) |
23 | } | 23 | } |
24 | 24 | ||
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' | |||
14 | import { VideoChannelModel } from '../../models/video/video-channel' | 14 | import { VideoChannelModel } from '../../models/video/video-channel' |
15 | import { areValidationErrors } from './utils' | 15 | import { areValidationErrors } from './utils' |
16 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' | 16 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' |
17 | import { ActorModel } from '../../models/activitypub/actor' | ||
17 | 18 | ||
18 | const listVideoAccountChannelsValidator = [ | 19 | const 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 | ] |