diff options
Diffstat (limited to 'server/middlewares/validators/actor-image.ts')
-rw-r--r-- | server/middlewares/validators/actor-image.ts | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/server/middlewares/validators/actor-image.ts b/server/middlewares/validators/actor-image.ts deleted file mode 100644 index 9dcf5e871..000000000 --- a/server/middlewares/validators/actor-image.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | import express from 'express' | ||
2 | import { body } from 'express-validator' | ||
3 | import { isActorImageFile } from '@server/helpers/custom-validators/actor-images' | ||
4 | import { cleanUpReqFiles } from '../../helpers/express-utils' | ||
5 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | ||
6 | import { areValidationErrors } from './shared' | ||
7 | |||
8 | const updateActorImageValidatorFactory = (fieldname: string) => ([ | ||
9 | body(fieldname).custom((value, { req }) => isActorImageFile(req.files, fieldname)).withMessage( | ||
10 | 'This file is not supported or too large. Please, make sure it is of the following type : ' + | ||
11 | CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME.join(', ') | ||
12 | ), | ||
13 | |||
14 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
15 | if (areValidationErrors(req, res)) return cleanUpReqFiles(req) | ||
16 | |||
17 | return next() | ||
18 | } | ||
19 | ]) | ||
20 | |||
21 | const updateAvatarValidator = updateActorImageValidatorFactory('avatarfile') | ||
22 | const updateBannerValidator = updateActorImageValidatorFactory('bannerfile') | ||
23 | |||
24 | export { | ||
25 | updateAvatarValidator, | ||
26 | updateBannerValidator | ||
27 | } | ||