2017-11-10 14:34:45 +01:00
|
|
|
import * as express from 'express'
|
2017-11-14 17:31:26 +01:00
|
|
|
import { body } from 'express-validator/check'
|
|
|
|
import { isRootActivityValid, logger } from '../../../helpers'
|
2017-11-27 17:30:46 +01:00
|
|
|
import { areValidationErrors } from '../utils'
|
2017-11-10 14:34:45 +01:00
|
|
|
|
|
|
|
const activityPubValidator = [
|
2017-11-14 17:31:26 +01:00
|
|
|
body('').custom((value, { req }) => isRootActivityValid(req.body)),
|
2017-11-10 14:34:45 +01:00
|
|
|
|
|
|
|
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
2017-11-30 14:15:17 +01:00
|
|
|
logger.debug('Checking activity pub parameters')
|
2017-11-10 14:34:45 +01:00
|
|
|
|
2017-11-27 17:30:46 +01:00
|
|
|
if (areValidationErrors(req, res)) return
|
|
|
|
|
|
|
|
return next()
|
2017-11-10 14:34:45 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
activityPubValidator
|
|
|
|
}
|