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