1
0
Fork 0
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:
Chocobozzz 2017-12-29 19:10:13 +01:00
parent 8b0d42ee37
commit c5911fd347
No known key found for this signature in database
GPG key ID: 583A612D890159BE
41 changed files with 498 additions and 177 deletions

View file

@ -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
}