mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-12-02 05:19:17 -06:00
27 lines
926 B
TypeScript
27 lines
926 B
TypeScript
import * as express from 'express'
|
|
import { body } from 'express-validator/check'
|
|
import { isAvatarFile } from '../../helpers/custom-validators/users'
|
|
import { areValidationErrors } from './utils'
|
|
import { CONSTRAINTS_FIELDS } from '../../initializers'
|
|
import { logger } from '../../helpers/logger'
|
|
import { cleanUpReqFiles } from '../../helpers/utils'
|
|
|
|
const updateAvatarValidator = [
|
|
body('avatarfile').custom((value, { req }) => isAvatarFile(req.files)).withMessage(
|
|
'This file is not supported or too large. Please, make sure it is of the following type : '
|
|
+ CONSTRAINTS_FIELDS.ACTORS.AVATAR.EXTNAME.join(', ')
|
|
),
|
|
|
|
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
|
logger.debug('Checking updateAvatarValidator parameters', { files: req.files })
|
|
|
|
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
|
|
|
return next()
|
|
}
|
|
]
|
|
|
|
export {
|
|
updateAvatarValidator
|
|
}
|