diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 16 |
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' |
15 | import { VideoModel } from '../../models/video/video' | 15 | import { VideoModel } from '../../models/video/video' |
16 | import { exists, isArray, isFileValid } from './misc' | 16 | import { exists, isArray, isFileValid } from './misc' |
17 | import { VideoChannelModel } from '../../models/video/video-channel' | ||
17 | 18 | ||
18 | const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS | 19 | const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS |
19 | const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES | 20 | const 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 | ||
128 | async 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 | ||
129 | export { | 144 | export { |
@@ -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 | } |