mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Begin to add avatar to actors
This commit is contained in:
parent
8b0d42ee37
commit
c5911fd347
41 changed files with 498 additions and 177 deletions
|
@ -1,7 +1,7 @@
|
|||
import * as validator from 'validator'
|
||||
import 'express-validator'
|
||||
|
||||
import { exists } from './misc'
|
||||
import { exists, isArray } from './misc'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers'
|
||||
import { UserRole } from '../../../shared'
|
||||
|
||||
|
@ -37,6 +37,22 @@ function isUserRoleValid (value: any) {
|
|||
return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined
|
||||
}
|
||||
|
||||
function isAvatarFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[]) {
|
||||
// Should have files
|
||||
if (!files) return false
|
||||
if (isArray(files)) return false
|
||||
|
||||
// Should have videofile file
|
||||
const avatarfile = files['avatarfile']
|
||||
if (!avatarfile || avatarfile.length === 0) return false
|
||||
|
||||
// The file should exist
|
||||
const file = avatarfile[0]
|
||||
if (!file || !file.originalname) return false
|
||||
|
||||
return new RegExp('^image/(png|jpeg)$', 'i').test(file.mimetype)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
|
@ -45,5 +61,6 @@ export {
|
|||
isUserVideoQuotaValid,
|
||||
isUserUsernameValid,
|
||||
isUserDisplayNSFWValid,
|
||||
isUserAutoPlayVideoValid
|
||||
isUserAutoPlayVideoValid,
|
||||
isAvatarFile
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue