aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/activitypub')
-rw-r--r--server/middlewares/validators/activitypub/activity.ts6
-rw-r--r--server/middlewares/validators/activitypub/signature.ts17
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator/check' 2import { body } from 'express-validator/check'
3import { isRootActivityValid, logger } from '../../../helpers' 3import { isRootActivityValid, logger } from '../../../helpers'
4import { checkErrors } from '../utils' 4import { areValidationErrors } from '../utils'
5 5
6const activityPubValidator = [ 6const 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 @@
1import { body } from 'express-validator/check'
2import * as express from 'express' 1import * as express from 'express'
3 2import { body } from 'express-validator/check'
4import { 3import { isDateValid, isSignatureCreatorValid, isSignatureTypeValid, isSignatureValueValid, logger } from '../../../helpers'
5 logger, 4import { areValidationErrors } from '../utils'
6 isDateValid,
7 isSignatureTypeValid,
8 isSignatureCreatorValid,
9 isSignatureValueValid
10} from '../../../helpers'
11import { checkErrors } from '../utils'
12 5
13const signatureValidator = [ 6const 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