diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-12 17:53:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-13 16:50:33 +0100 |
commit | 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch) | |
tree | e5ca358287fca6ecacce83defcf23af1e8e9f419 /server/middlewares/validators/videos.ts | |
parent | c893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff) | |
download | PeerTube-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.ts | 17 |
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import 'express-validator' | ||
2 | import { body, param, query } from 'express-validator/check' | 3 | import { body, param, query } from 'express-validator/check' |
3 | import { UserRight, VideoPrivacy } from '../../../shared' | 4 | import { UserRight, VideoPrivacy } from '../../../shared' |
5 | import { getDurationFromVideoFile, logger } from '../../helpers' | ||
4 | import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' | 6 | import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' |
5 | import { | 7 | import { |
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' |
19 | import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils' | ||
20 | import { logger } from '../../helpers/logger' | ||
21 | import { CONSTRAINTS_FIELDS } from '../../initializers' | 21 | import { CONSTRAINTS_FIELDS } from '../../initializers' |
22 | import { database as db } from '../../initializers/database' | 22 | import { UserModel } from '../../models/account/user' |
23 | import { UserInstance } from '../../models/account/user-interface' | 23 | import { VideoModel } from '../../models/video/video' |
24 | import { VideoInstance } from '../../models/video/video-interface' | 24 | import { VideoChannelModel } from '../../models/video/video-channel' |
25 | import { VideoShareModel } from '../../models/video/video-share' | ||
25 | import { authenticate } from '../oauth' | 26 | import { authenticate } from '../oauth' |
26 | import { areValidationErrors } from './utils' | 27 | import { 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 | ||
252 | function checkUserCanDeleteVideo (user: UserInstance, video: VideoInstance, res: express.Response) { | 253 | function 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) |