aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/videos.ts')
-rw-r--r--server/middlewares/validators/videos.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index 10625e41d..b52d5f285 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -1,6 +1,8 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator'
2import { body, param, query } from 'express-validator/check' 3import { body, param, query } from 'express-validator/check'
3import { UserRight, VideoPrivacy } from '../../../shared' 4import { UserRight, VideoPrivacy } from '../../../shared'
5import { getDurationFromVideoFile, logger } from '../../helpers'
4import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' 6import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
5import { 7import {
6 isVideoAbuseReasonValid, 8 isVideoAbuseReasonValid,
@@ -16,12 +18,11 @@ import {
16 isVideoRatingTypeValid, 18 isVideoRatingTypeValid,
17 isVideoTagsValid 19 isVideoTagsValid
18} from '../../helpers/custom-validators/videos' 20} from '../../helpers/custom-validators/videos'
19import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils'
20import { logger } from '../../helpers/logger'
21import { CONSTRAINTS_FIELDS } from '../../initializers' 21import { CONSTRAINTS_FIELDS } from '../../initializers'
22import { database as db } from '../../initializers/database' 22import { UserModel } from '../../models/account/user'
23import { UserInstance } from '../../models/account/user-interface' 23import { VideoModel } from '../../models/video/video'
24import { VideoInstance } from '../../models/video/video-interface' 24import { VideoChannelModel } from '../../models/video/video-channel'
25import { VideoShareModel } from '../../models/video/video-share'
25import { authenticate } from '../oauth' 26import { authenticate } from '../oauth'
26import { areValidationErrors } from './utils' 27import { areValidationErrors } from './utils'
27 28
@@ -48,7 +49,7 @@ const videosAddValidator = [
48 const videoFile: Express.Multer.File = req.files['videofile'][0] 49 const videoFile: Express.Multer.File = req.files['videofile'][0]
49 const user = res.locals.oauth.token.User 50 const user = res.locals.oauth.token.User
50 51
51 const videoChannel = await db.VideoChannel.loadByIdAndAccount(req.body.channelId, user.Account.id) 52 const videoChannel = await VideoChannelModel.loadByIdAndAccount(req.body.channelId, user.Account.id)
52 if (!videoChannel) { 53 if (!videoChannel) {
53 res.status(400) 54 res.status(400)
54 .json({ error: 'Unknown video video channel for this account.' }) 55 .json({ error: 'Unknown video video channel for this account.' })
@@ -221,7 +222,7 @@ const videosShareValidator = [
221 if (areValidationErrors(req, res)) return 222 if (areValidationErrors(req, res)) return
222 if (!await isVideoExist(req.params.id, res)) return 223 if (!await isVideoExist(req.params.id, res)) return
223 224
224 const share = await db.VideoShare.load(req.params.accountId, res.locals.video.id, undefined) 225 const share = await VideoShareModel.load(req.params.accountId, res.locals.video.id, undefined)
225 if (!share) { 226 if (!share) {
226 return res.status(404) 227 return res.status(404)
227 .end() 228 .end()
@@ -249,7 +250,7 @@ export {
249 250
250// --------------------------------------------------------------------------- 251// ---------------------------------------------------------------------------
251 252
252function checkUserCanDeleteVideo (user: UserInstance, video: VideoInstance, res: express.Response) { 253function checkUserCanDeleteVideo (user: UserModel, video: VideoModel, res: express.Response) {
253 // Retrieve the user who did the request 254 // Retrieve the user who did the request
254 if (video.isOwned() === false) { 255 if (video.isOwned() === false) {
255 res.status(403) 256 res.status(403)