aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/videos.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 23d2d8ac6..c35db49ac 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -14,6 +14,7 @@ import {
14} from '../../initializers' 14} from '../../initializers'
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'
17 18
18const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS 19const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
19const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES 20const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
@@ -124,6 +125,20 @@ async function isVideoExist (id: string, res: Response) {
124 return true 125 return true
125} 126}
126 127
128async function isVideoChannelOfAccountExist (channelId: number, accountId: number, res: Response) {
129 const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, accountId)
130 if (!videoChannel) {
131 res.status(400)
132 .json({ error: 'Unknown video video channel for this account.' })
133 .end()
134
135 return false
136 }
137
138 res.locals.videoChannel = videoChannel
139 return true
140}
141
127// --------------------------------------------------------------------------- 142// ---------------------------------------------------------------------------
128 143
129export { 144export {
@@ -146,5 +161,6 @@ export {
146 isVideoFileSizeValid, 161 isVideoFileSizeValid,
147 isVideoExist, 162 isVideoExist,
148 isVideoImage, 163 isVideoImage,
164 isVideoChannelOfAccountExist,
149 isVideoSupportValid 165 isVideoSupportValid
150} 166}