aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/videos.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index edafba6e2..dd207c787 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -152,13 +152,15 @@ function checkUserCanManageVideo (user: UserModel, video: VideoModel, right: Use
152 return true 152 return true
153} 153}
154 154
155async function isVideoExist (id: string, res: Response) { 155async function isVideoExist (id: string, res: Response, fetchType: 'all' | 'only-video' | 'id' | 'none' = 'all') {
156 let video: VideoModel | null 156 let video: VideoModel | null
157 157
158 if (validator.isInt(id)) { 158 if (fetchType === 'all') {
159 video = await VideoModel.loadAndPopulateAccountAndServerAndTags(+id) 159 video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id)
160 } else { // UUID 160 } else if (fetchType === 'only-video') {
161 video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(id) 161 video = await VideoModel.load(id)
162 } else if (fetchType === 'id' || fetchType === 'none') {
163 video = await VideoModel.loadOnlyId(id)
162 } 164 }
163 165
164 if (video === null) { 166 if (video === null) {
@@ -169,7 +171,7 @@ async function isVideoExist (id: string, res: Response) {
169 return false 171 return false
170 } 172 }
171 173
172 res.locals.video = video 174 if (fetchType !== 'none') res.locals.video = video
173 return true 175 return true
174} 176}
175 177