From 4157cdb13748cb6e8ce7081d062a8778554cc5a7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Sep 2018 11:16:23 +0200 Subject: Refractor videos AP functions --- server/helpers/custom-validators/videos.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'server/helpers/custom-validators/videos.ts') 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' import { VideoChannelModel } from '../../models/video/video-channel' import { UserModel } from '../../models/account/user' import * as magnetUtil from 'magnet-uri' +import { fetchVideo, VideoFetchType } from '../video' const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS @@ -152,17 +153,8 @@ function checkUserCanManageVideo (user: UserModel, video: VideoModel, right: Use return true } -export type VideoFetchType = 'all' | 'only-video' | 'id' | 'none' async function isVideoExist (id: string, res: Response, fetchType: VideoFetchType = 'all') { - let video: VideoModel | null - - if (fetchType === 'all') { - video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id) - } else if (fetchType === 'only-video') { - video = await VideoModel.load(id) - } else if (fetchType === 'id' || fetchType === 'none') { - video = await VideoModel.loadOnlyId(id) - } + const video = await fetchVideo(id, fetchType) if (video === null) { res.status(404) -- cgit v1.2.3