From 012580d98f489e599d44a9a2a0bdc892b9455a90 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 May 2021 10:21:39 +0200 Subject: Cleanup We must not expose private actor objects to clients Just make 2 GET requests on channel/accounts instead --- server/helpers/middlewares/video-channels.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'server/helpers/middlewares') diff --git a/server/helpers/middlewares/video-channels.ts b/server/helpers/middlewares/video-channels.ts index e30ea90b3..602555921 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, sendNotFound = true) { +async function doesLocalVideoChannelNameExist (name: string, res: express.Response) { const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) - return processVideoChannelExist(videoChannel, res, sendNotFound) + return processVideoChannelExist(videoChannel, res) } -async function doesVideoChannelIdExist (id: number, res: express.Response, sendNotFound = true) { +async function doesVideoChannelIdExist (id: number, res: express.Response) { const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) - return processVideoChannelExist(videoChannel, res, sendNotFound) + return processVideoChannelExist(videoChannel, res) } -async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response, sendNotFound = true) { +async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) { const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain) - return processVideoChannelExist(videoChannel, res, sendNotFound) + return processVideoChannelExist(videoChannel, res) } // --------------------------------------------------------------------------- @@ -29,12 +29,10 @@ export { doesVideoChannelNameWithHostExist } -function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response, sendNotFound = true) { +function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response) { if (!videoChannel) { - if (sendNotFound) { - res.status(HttpStatusCode.NOT_FOUND_404) - .json({ error: 'Video channel not found' }) - } + res.status(HttpStatusCode.NOT_FOUND_404) + .json({ error: 'Video channel not found' }) return false } -- cgit v1.2.3