From b8f4167fb6fa448125aeecff80b201d74e27fe6a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 28 Nov 2019 11:37:32 +0100 Subject: Only display accepted followers/followings in about page --- server/middlewares/validators/follows.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts index 788735663..454f9f2b8 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/middlewares/validators/follows.ts @@ -1,5 +1,5 @@ import * as express from 'express' -import { body, param } from 'express-validator' +import { body, param, query } from 'express-validator' import { isTestInstance } from '../../helpers/core-utils' import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' import { logger } from '../../helpers/logger' @@ -11,6 +11,19 @@ import { ActorModel } from '../../models/activitypub/actor' import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' import { isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' import { MActorFollowActorsDefault } from '@server/typings/models' +import { isFollowStateValid } from '@server/helpers/custom-validators/follows' + +const listFollowsValidator = [ + query('state') + .optional() + .custom(isFollowStateValid).withMessage('Should have a valid follow state'), + + (req: express.Request, res: express.Response, next: express.NextFunction) => { + if (areValidationErrors(req, res)) return + + return next() + } +] const followValidator = [ body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'), @@ -110,5 +123,6 @@ export { followValidator, removeFollowingValidator, getFollowerValidator, - acceptOrRejectFollowerValidator + acceptOrRejectFollowerValidator, + listFollowsValidator } -- cgit v1.2.3