From b225148dfb0e1c6d1377a3fd3b4e69841d247fbd Mon Sep 17 00:00:00 2001 From: John Livingston Date: Sat, 1 May 2021 19:01:31 +0200 Subject: [PATCH] 403 status when video invalid. --- server/lib/routers/api.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/lib/routers/api.ts b/server/lib/routers/api.ts index 820a6db1..c79f7e2d 100644 --- a/server/lib/routers/api.ts +++ b/server/lib/routers/api.ts @@ -37,7 +37,9 @@ async function initApiRouter (options: RegisterServerOptions): Promise { const video = await peertubeHelpers.videos.loadByIdOrUUID(jid) if (!video) { - throw new Error('Video not found') + logger.warn(`Video ${jid} not found`) + res.sendStatus(403) + return } // check settings (chat enabled for this video?) const settings = await options.settingsManager.getSettings([ @@ -52,7 +54,9 @@ async function initApiRouter (options: RegisterServerOptions): Promise { 'chat-all-non-lives': settings['chat-all-non-lives'] as boolean, 'chat-videos-list': settings['chat-videos-list'] as string }, video)) { - throw new Error('Chat is not activated for this video') + logger.warn(`Video ${jid} has not chat activated`) + res.sendStatus(403) + return } // TODO: fill missing informations