diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-07 10:36:13 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-04-08 10:07:53 +0200 |
commit | 213e30ef90806369529684ac9c247d73b8dc7928 (patch) | |
tree | 7f834f2485a074b1d3052745fa5236d34c0f26db /server/helpers/custom-validators/users.ts | |
parent | 2cb03dc1f4e01ba491c36caff30c33fe9c5bad89 (diff) | |
download | PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.tar.gz PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.tar.zst PeerTube-213e30ef90806369529684ac9c247d73b8dc7928.zip |
Add banner tests
Diffstat (limited to 'server/helpers/custom-validators/users.ts')
-rw-r--r-- | server/helpers/custom-validators/users.ts | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 85f3634c8..5b21c3529 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -3,7 +3,7 @@ import validator from 'validator' | |||
3 | import { UserRole } from '../../../shared' | 3 | import { UserRole } from '../../../shared' |
4 | import { isEmailEnabled } from '../../initializers/config' | 4 | import { isEmailEnabled } from '../../initializers/config' |
5 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' | 5 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' |
6 | import { exists, isArray, isBooleanValid, isFileValid } from './misc' | 6 | import { exists, isArray, isBooleanValid } from './misc' |
7 | 7 | ||
8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS | 8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS |
9 | 9 | ||
@@ -97,14 +97,6 @@ function isUserRoleValid (value: any) { | |||
97 | return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined | 97 | return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined |
98 | } | 98 | } |
99 | 99 | ||
100 | const avatarMimeTypes = CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME | ||
101 | .map(v => v.replace('.', '')) | ||
102 | .join('|') | ||
103 | const avatarMimeTypesRegex = `image/(${avatarMimeTypes})` | ||
104 | function isAvatarFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[]) { | ||
105 | return isFileValid(files, avatarMimeTypesRegex, 'avatarfile', CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max) | ||
106 | } | ||
107 | |||
108 | // --------------------------------------------------------------------------- | 100 | // --------------------------------------------------------------------------- |
109 | 101 | ||
110 | export { | 102 | export { |
@@ -128,6 +120,5 @@ export { | |||
128 | isUserDisplayNameValid, | 120 | isUserDisplayNameValid, |
129 | isUserDescriptionValid, | 121 | isUserDescriptionValid, |
130 | isNoInstanceConfigWarningModal, | 122 | isNoInstanceConfigWarningModal, |
131 | isNoWelcomeModal, | 123 | isNoWelcomeModal |
132 | isAvatarFile | ||
133 | } | 124 | } |