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