From 0f320037e689b2778959c12ddd4ce790f6e4ae4f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 11 May 2018 15:10:13 +0200 Subject: Add ability to update a video channel --- server/helpers/custom-validators/videos.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'server/helpers/custom-validators') 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 { } from '../../initializers' import { VideoModel } from '../../models/video/video' import { exists, isArray, isFileValid } from './misc' +import { VideoChannelModel } from '../../models/video/video-channel' const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES @@ -124,6 +125,20 @@ async function isVideoExist (id: string, res: Response) { return true } +async function isVideoChannelOfAccountExist (channelId: number, accountId: number, res: Response) { + const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, accountId) + if (!videoChannel) { + res.status(400) + .json({ error: 'Unknown video video channel for this account.' }) + .end() + + return false + } + + res.locals.videoChannel = videoChannel + return true +} + // --------------------------------------------------------------------------- export { @@ -146,5 +161,6 @@ export { isVideoFileSizeValid, isVideoExist, isVideoImage, + isVideoChannelOfAccountExist, isVideoSupportValid } -- cgit v1.2.3