mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Server: update express-validator
This commit is contained in:
parent
c70e0710b3
commit
f6f7dfee01
3 changed files with 19 additions and 5 deletions
|
@ -21,7 +21,8 @@ const videosValidators = {
|
|||
isVideoExtnameValid,
|
||||
isVideoRemoteIdValid,
|
||||
isVideoAbuseReasonValid,
|
||||
isVideoAbuseReporterUsernameValid
|
||||
isVideoAbuseReporterUsernameValid,
|
||||
isVideoFile
|
||||
}
|
||||
|
||||
function isVideoAuthorValid (value) {
|
||||
|
@ -81,6 +82,21 @@ function isVideoAbuseReporterUsernameValid (value) {
|
|||
return usersValidators.isUserUsernameValid(value)
|
||||
}
|
||||
|
||||
function isVideoFile (value, files) {
|
||||
// Should have files
|
||||
if (!files) return false
|
||||
|
||||
// Should have videofile file
|
||||
const videofile = files.videofile
|
||||
if (!videofile || videofile.length === 0) return false
|
||||
|
||||
// The file should exist
|
||||
const file = videofile[0]
|
||||
if (!file || !file.originalname) return false
|
||||
|
||||
return new RegExp('^video/(webm|mp4|ogg)$', 'i').test(file.mimetype)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = videosValidators
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue