aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-09-25 16:19:35 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitfb7194043d0486ce0a6a40b2ffbdf32878c33a6f (patch)
tree6ed304a5d730a75da0a4460b3009df88684fa598 /server/middlewares/validators/videos
parenta5cf76afa378aae81af2a9b0ce548e5d2582f832 (diff)
downloadPeerTube-fb7194043d0486ce0a6a40b2ffbdf32878c33a6f.tar.gz
PeerTube-fb7194043d0486ce0a6a40b2ffbdf32878c33a6f.tar.zst
PeerTube-fb7194043d0486ce0a6a40b2ffbdf32878c33a6f.zip
Check live duration and size
Diffstat (limited to 'server/middlewares/validators/videos')
-rw-r--r--server/middlewares/validators/videos/videos.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index b022b2c23..ff90e347a 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -1,5 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query, ValidationChain } from 'express-validator' 2import { body, param, query, ValidationChain } from 'express-validator'
3import { isAbleToUploadVideo } from '@server/lib/user'
3import { getServerActor } from '@server/models/application/application' 4import { getServerActor } from '@server/models/application/application'
4import { MVideoFullLight } from '@server/types/models' 5import { MVideoFullLight } from '@server/types/models'
5import { ServerErrorCode, UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared' 6import { ServerErrorCode, UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared'
@@ -73,7 +74,7 @@ const videosAddValidator = getCommonVideoEditAttributes().concat([
73 74
74 if (!await doesVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) 75 if (!await doesVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
75 76
76 if (await user.isAbleToUploadVideo(videoFile) === false) { 77 if (await isAbleToUploadVideo(user.id, videoFile.size) === false) {
77 res.status(403) 78 res.status(403)
78 .json({ error: 'The user video quota is exceeded with this video.' }) 79 .json({ error: 'The user video quota is exceeded with this video.' })
79 80
@@ -291,7 +292,7 @@ const videosAcceptChangeOwnershipValidator = [
291 292
292 const user = res.locals.oauth.token.User 293 const user = res.locals.oauth.token.User
293 const videoChangeOwnership = res.locals.videoChangeOwnership 294 const videoChangeOwnership = res.locals.videoChangeOwnership
294 const isAble = await user.isAbleToUploadVideo(videoChangeOwnership.Video.getMaxQualityFile()) 295 const isAble = await isAbleToUploadVideo(user.id, videoChangeOwnership.Video.getMaxQualityFile().size)
295 if (isAble === false) { 296 if (isAble === false) {
296 res.status(403) 297 res.status(403)
297 .json({ error: 'The user video quota is exceeded with this video.' }) 298 .json({ error: 'The user video quota is exceeded with this video.' })