return processVideoChannelExist(videoChannel, res)
}
-async function isVideoChannelIdExist (id: string, res: express.Response) {
+async function isVideoChannelIdExist (id: number | string, res: express.Response) {
let videoChannel: VideoChannelModel
- if (validator.isInt(id)) {
+ if (validator.isInt('' + id)) {
videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
} else { // UUID
- videoChannel = await VideoChannelModel.loadByUUIDAndPopulateAccount(id)
+ videoChannel = await VideoChannelModel.loadByUUIDAndPopulateAccount('' + id)
}
return processVideoChannelExist(videoChannel, res)
}
async function isVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) {
- const [ name, host ] = nameWithDomain.split('@')
- let videoChannel: VideoChannelModel
-
- if (!host || host === CONFIG.WEBSERVER.HOST) videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
- else videoChannel = await VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host)
+ const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain)
return processVideoChannelExist(videoChannel, res)
}