diff options
Diffstat (limited to 'server/middlewares/validators/activitypub')
-rw-r--r-- | server/middlewares/validators/activitypub/activity.ts | 6 | ||||
-rw-r--r-- | server/middlewares/validators/activitypub/signature.ts | 17 |
2 files changed, 10 insertions, 13 deletions
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts index 0de8b2d85..8aa82298c 100644 --- a/server/middlewares/validators/activitypub/activity.ts +++ b/server/middlewares/validators/activitypub/activity.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body } from 'express-validator/check' | 2 | import { body } from 'express-validator/check' |
3 | import { isRootActivityValid, logger } from '../../../helpers' | 3 | import { isRootActivityValid, logger } from '../../../helpers' |
4 | import { checkErrors } from '../utils' | 4 | import { areValidationErrors } from '../utils' |
5 | 5 | ||
6 | const activityPubValidator = [ | 6 | const activityPubValidator = [ |
7 | body('').custom((value, { req }) => isRootActivityValid(req.body)), | 7 | body('').custom((value, { req }) => isRootActivityValid(req.body)), |
@@ -9,7 +9,9 @@ const activityPubValidator = [ | |||
9 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 9 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
10 | logger.debug('Checking activity pub parameters', { parameters: req.body }) | 10 | logger.debug('Checking activity pub parameters', { parameters: req.body }) |
11 | 11 | ||
12 | checkErrors(req, res, next) | 12 | if (areValidationErrors(req, res)) return |
13 | |||
14 | return next() | ||
13 | } | 15 | } |
14 | ] | 16 | ] |
15 | 17 | ||
diff --git a/server/middlewares/validators/activitypub/signature.ts b/server/middlewares/validators/activitypub/signature.ts index 0ce15c1f6..360685512 100644 --- a/server/middlewares/validators/activitypub/signature.ts +++ b/server/middlewares/validators/activitypub/signature.ts | |||
@@ -1,14 +1,7 @@ | |||
1 | import { body } from 'express-validator/check' | ||
2 | import * as express from 'express' | 1 | import * as express from 'express' |
3 | 2 | import { body } from 'express-validator/check' | |
4 | import { | 3 | import { isDateValid, isSignatureCreatorValid, isSignatureTypeValid, isSignatureValueValid, logger } from '../../../helpers' |
5 | logger, | 4 | import { areValidationErrors } from '../utils' |
6 | isDateValid, | ||
7 | isSignatureTypeValid, | ||
8 | isSignatureCreatorValid, | ||
9 | isSignatureValueValid | ||
10 | } from '../../../helpers' | ||
11 | import { checkErrors } from '../utils' | ||
12 | 5 | ||
13 | const signatureValidator = [ | 6 | const signatureValidator = [ |
14 | body('signature.type').custom(isSignatureTypeValid).withMessage('Should have a valid signature type'), | 7 | body('signature.type').custom(isSignatureTypeValid).withMessage('Should have a valid signature type'), |
@@ -19,7 +12,9 @@ const signatureValidator = [ | |||
19 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 12 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
20 | logger.debug('Checking activitypub signature parameter', { parameters: { signature: req.body.signature } }) | 13 | logger.debug('Checking activitypub signature parameter', { parameters: { signature: req.body.signature } }) |
21 | 14 | ||
22 | checkErrors(req, res, next) | 15 | if (areValidationErrors(req, res)) return |
16 | |||
17 | return next() | ||
23 | } | 18 | } |
24 | ] | 19 | ] |
25 | 20 | ||