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.ts12
1 files changed, 2 insertions, 10 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index c9ef8445d..9875c68bd 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -18,6 +18,7 @@ import { exists, isArray, isFileValid } from './misc'
18import { VideoChannelModel } from '../../models/video/video-channel' 18import { VideoChannelModel } from '../../models/video/video-channel'
19import { UserModel } from '../../models/account/user' 19import { UserModel } from '../../models/account/user'
20import * as magnetUtil from 'magnet-uri' 20import * as magnetUtil from 'magnet-uri'
21import { fetchVideo, VideoFetchType } from '../video'
21 22
22const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS 23const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
23 24
@@ -152,17 +153,8 @@ function checkUserCanManageVideo (user: UserModel, video: VideoModel, right: Use
152 return true 153 return true
153} 154}
154 155
155export type VideoFetchType = 'all' | 'only-video' | 'id' | 'none'
156async function isVideoExist (id: string, res: Response, fetchType: VideoFetchType = 'all') { 156async function isVideoExist (id: string, res: Response, fetchType: VideoFetchType = 'all') {
157 let video: VideoModel | null 157 const video = await fetchVideo(id, fetchType)
158
159 if (fetchType === 'all') {
160 video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id)
161 } else if (fetchType === 'only-video') {
162 video = await VideoModel.load(id)
163 } else if (fetchType === 'id' || fetchType === 'none') {
164 video = await VideoModel.loadOnlyId(id)
165 }
166 158
167 if (video === null) { 159 if (video === null) {
168 res.status(404) 160 res.status(404)