From 265ba139ebf56bbdc1c65f6ea4f367774c691fc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 3 Jan 2018 16:38:50 +0100 Subject: Send account activitypub update events --- server/middlewares/validators/account.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'server/middlewares/validators/account.ts') diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts index 3573a9a50..ebc2fcf2d 100644 --- a/server/middlewares/validators/account.ts +++ b/server/middlewares/validators/account.ts @@ -1,6 +1,7 @@ import * as express from 'express' import { param } from 'express-validator/check' -import { isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts' +import { isAccountIdExist, isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts' +import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' import { logger } from '../../helpers/logger' import { areValidationErrors } from './utils' @@ -17,8 +18,22 @@ const localAccountValidator = [ } ] +const accountsGetValidator = [ + param('id').custom(isIdOrUUIDValid).withMessage('Should have a valid id'), + + async (req: express.Request, res: express.Response, next: express.NextFunction) => { + logger.debug('Checking accountsGetValidator parameters', { parameters: req.params }) + + if (areValidationErrors(req, res)) return + if (!await isAccountIdExist(req.params.id, res)) return + + return next() + } +] + // --------------------------------------------------------------------------- export { - localAccountValidator + localAccountValidator, + accountsGetValidator } -- cgit v1.2.3