aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/videos.ts21
1 files changed, 18 insertions, 3 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 002324fe0..0c268a684 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -3,7 +3,7 @@ import 'express-validator'
3import { values } from 'lodash' 3import { values } from 'lodash'
4import 'multer' 4import 'multer'
5import * as validator from 'validator' 5import * as validator from 'validator'
6import { VideoRateType } from '../../../shared' 6import { UserRight, VideoRateType } from '../../../shared'
7import { 7import {
8 CONSTRAINTS_FIELDS, 8 CONSTRAINTS_FIELDS,
9 VIDEO_CATEGORIES, 9 VIDEO_CATEGORIES,
@@ -15,6 +15,7 @@ import {
15import { VideoModel } from '../../models/video/video' 15import { VideoModel } from '../../models/video/video'
16import { exists, isArray, isFileValid } from './misc' 16import { exists, isArray, isFileValid } from './misc'
17import { VideoChannelModel } from '../../models/video/video-channel' 17import { VideoChannelModel } from '../../models/video/video-channel'
18import { UserModel } from '../../models/account/user'
18 19
19const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS 20const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
20const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES 21const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
@@ -127,8 +128,22 @@ async function isVideoExist (id: string, res: Response) {
127 return true 128 return true
128} 129}
129 130
130async function isVideoChannelOfAccountExist (channelId: number, accountId: number, res: Response) { 131async function isVideoChannelOfAccountExist (channelId: number, user: UserModel, res: Response) {
131 const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, accountId) 132 if (user.hasRight(UserRight.UPDATE_ANY_VIDEO) === true) {
133 const videoChannel = await VideoChannelModel.loadAndPopulateAccount(channelId)
134 if (!videoChannel) {
135 res.status(400)
136 .json({ error: 'Unknown video video channel on this instance.' })
137 .end()
138
139 return false
140 }
141
142 res.locals.videoChannel = videoChannel
143 return true
144 }
145
146 const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, user.Account.id)
132 if (!videoChannel) { 147 if (!videoChannel) {
133 res.status(400) 148 res.status(400)
134 .json({ error: 'Unknown video video channel for this account.' }) 149 .json({ error: 'Unknown video video channel for this account.' })