X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fmiddlewares%2Fvideo-channels.ts;h=e30ea90b3628d39427c25a8514d279020eb6d3a9;hb=d6d96bed80700830063c6055969d2d2ff46c63c6;hp=e6eab65a28a0d43238bdc6b7ee9ccca2e6e82082;hpb=dc48fdbe68e9dd3a3a6028181e61d8595d98e654;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/middlewares/video-channels.ts b/server/helpers/middlewares/video-channels.ts index e6eab65a2..e30ea90b3 100644 --- a/server/helpers/middlewares/video-channels.ts +++ b/server/helpers/middlewares/video-channels.ts @@ -3,22 +3,22 @@ import { MChannelBannerAccountDefault } from '@server/types/models' import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { VideoChannelModel } from '../../models/video/video-channel' -async function doesLocalVideoChannelNameExist (name: string, res: express.Response) { +async function doesLocalVideoChannelNameExist (name: string, res: express.Response, sendNotFound = true) { const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) - return processVideoChannelExist(videoChannel, res) + return processVideoChannelExist(videoChannel, res, sendNotFound) } -async function doesVideoChannelIdExist (id: number, res: express.Response) { +async function doesVideoChannelIdExist (id: number, res: express.Response, sendNotFound = true) { const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) - return processVideoChannelExist(videoChannel, res) + return processVideoChannelExist(videoChannel, res, sendNotFound) } -async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) { +async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response, sendNotFound = true) { const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain) - return processVideoChannelExist(videoChannel, res) + return processVideoChannelExist(videoChannel, res, sendNotFound) } // --------------------------------------------------------------------------- @@ -29,10 +29,12 @@ export { doesVideoChannelNameWithHostExist } -function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response) { +function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response, sendNotFound = true) { if (!videoChannel) { - res.status(HttpStatusCode.NOT_FOUND_404) - .json({ error: 'Video channel not found' }) + if (sendNotFound) { + res.status(HttpStatusCode.NOT_FOUND_404) + .json({ error: 'Video channel not found' }) + } return false }