1 import * as express from 'express'
2 import { VideoChannelModel } from '../../models/video/video-channel'
3 import { MChannelAccountDefault } from '@server/types/models'
5 async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
6 const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
8 return processVideoChannelExist(videoChannel, res)
11 async function doesVideoChannelIdExist (id: number, res: express.Response) {
12 const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
14 return processVideoChannelExist(videoChannel, res)
17 async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) {
18 const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain)
20 return processVideoChannelExist(videoChannel, res)
23 // ---------------------------------------------------------------------------
26 doesLocalVideoChannelNameExist,
27 doesVideoChannelIdExist,
28 doesVideoChannelNameWithHostExist
31 function processVideoChannelExist (videoChannel: MChannelAccountDefault, res: express.Response) {
34 .json({ error: 'Video channel not found' })
40 res.locals.videoChannel = videoChannel