1 import * as express from 'express'
2 import { VideoChannelModel } from '@server/models/video/video-channel'
3 import { MChannelBannerAccountDefault } from '@server/types/models'
4 import { HttpStatusCode } from '@shared/models'
6 async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
7 const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
9 return processVideoChannelExist(videoChannel, res)
12 async function doesVideoChannelIdExist (id: number, res: express.Response) {
13 const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
15 return processVideoChannelExist(videoChannel, res)
18 async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) {
19 const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain)
21 return processVideoChannelExist(videoChannel, res)
24 // ---------------------------------------------------------------------------
27 doesLocalVideoChannelNameExist,
28 doesVideoChannelIdExist,
29 doesVideoChannelNameWithHostExist
32 function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response) {
35 status: HttpStatusCode.NOT_FOUND_404,
36 message: 'Video channel not found'
41 res.locals.videoChannel = videoChannel