1 import * as express from 'express'
2 import { VideoChannelModel } from '../../models/video/video-channel'
4 async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
5 const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
7 return processVideoChannelExist(videoChannel, res)
10 async function doesVideoChannelIdExist (id: number, res: express.Response) {
11 const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
13 return processVideoChannelExist(videoChannel, res)
16 async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) {
17 const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain)
19 return processVideoChannelExist(videoChannel, res)
22 // ---------------------------------------------------------------------------
25 doesLocalVideoChannelNameExist,
26 doesVideoChannelIdExist,
27 doesVideoChannelNameWithHostExist
30 function processVideoChannelExist (videoChannel: VideoChannelModel, res: express.Response) {
33 .json({ error: 'Video channel not found' })
39 res.locals.videoChannel = videoChannel