]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/middlewares/validators/avatar.ts
Ability to programmatically control embeds (#776)
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / avatar.ts
CommitLineData
4bbfc6c6
C
1import * as express from 'express'
2import { body } from 'express-validator/check'
3import { isAvatarFile } from '../../helpers/custom-validators/users'
4import { areValidationErrors } from './utils'
5import { CONSTRAINTS_FIELDS } from '../../initializers'
6import { logger } from '../../helpers/logger'
7
8const updateAvatarValidator = [
9 body('avatarfile').custom((value, { req }) => isAvatarFile(req.files)).withMessage(
10 'This file is not supported or too large. Please, make sure it is of the following type : '
11 + CONSTRAINTS_FIELDS.ACTORS.AVATAR.EXTNAME.join(', ')
12 ),
13
14 (req: express.Request, res: express.Response, next: express.NextFunction) => {
15 logger.debug('Checking updateAvatarValidator parameters', { files: req.files })
16
17 if (areValidationErrors(req, res)) return
18
19 return next()
20 }
21]
22
23export {
24 updateAvatarValidator
25}