diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/follows.ts | 18 |
1 files changed, 16 insertions, 2 deletions
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { isTestInstance } from '../../helpers/core-utils' | 3 | import { isTestInstance } from '../../helpers/core-utils' |
4 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' | 4 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' |
5 | import { logger } from '../../helpers/logger' | 5 | import { logger } from '../../helpers/logger' |
@@ -11,6 +11,19 @@ import { ActorModel } from '../../models/activitypub/actor' | |||
11 | import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' | 11 | import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' |
12 | import { isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' | 12 | import { isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' |
13 | import { MActorFollowActorsDefault } from '@server/typings/models' | 13 | import { MActorFollowActorsDefault } from '@server/typings/models' |
14 | import { isFollowStateValid } from '@server/helpers/custom-validators/follows' | ||
15 | |||
16 | const listFollowsValidator = [ | ||
17 | query('state') | ||
18 | .optional() | ||
19 | .custom(isFollowStateValid).withMessage('Should have a valid follow state'), | ||
20 | |||
21 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
22 | if (areValidationErrors(req, res)) return | ||
23 | |||
24 | return next() | ||
25 | } | ||
26 | ] | ||
14 | 27 | ||
15 | const followValidator = [ | 28 | const followValidator = [ |
16 | body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'), | 29 | body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'), |
@@ -110,5 +123,6 @@ export { | |||
110 | followValidator, | 123 | followValidator, |
111 | removeFollowingValidator, | 124 | removeFollowingValidator, |
112 | getFollowerValidator, | 125 | getFollowerValidator, |
113 | acceptOrRejectFollowerValidator | 126 | acceptOrRejectFollowerValidator, |
127 | listFollowsValidator | ||
114 | } | 128 | } |