aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-12 17:53:50 +0100
committerChocobozzz <me@florianbigard.com>2017-12-13 16:50:33 +0100
commit3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch)
treee5ca358287fca6ecacce83defcf23af1e8e9f419 /server/middlewares/validators/videos.ts
parentc893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff)
downloadPeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.gz
PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.zst
PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.zip
Move models to typescript-sequelize
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)