diff options
Diffstat (limited to 'server/helpers/middlewares/video-channels.ts')
-rw-r--r-- | server/helpers/middlewares/video-channels.ts | 20 |
1 files changed, 11 insertions, 9 deletions
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' | |||
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
4 | import { VideoChannelModel } from '../../models/video/video-channel' | 4 | import { VideoChannelModel } from '../../models/video/video-channel' |
5 | 5 | ||
6 | async function doesLocalVideoChannelNameExist (name: string, res: express.Response) { | 6 | async function doesLocalVideoChannelNameExist (name: string, res: express.Response, sendNotFound = true) { |
7 | const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) | 7 | const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) |
8 | 8 | ||
9 | return processVideoChannelExist(videoChannel, res) | 9 | return processVideoChannelExist(videoChannel, res, sendNotFound) |
10 | } | 10 | } |
11 | 11 | ||
12 | async function doesVideoChannelIdExist (id: number, res: express.Response) { | 12 | async function doesVideoChannelIdExist (id: number, res: express.Response, sendNotFound = true) { |
13 | const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) | 13 | const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) |
14 | 14 | ||
15 | return processVideoChannelExist(videoChannel, res) | 15 | return processVideoChannelExist(videoChannel, res, sendNotFound) |
16 | } | 16 | } |
17 | 17 | ||
18 | async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) { | 18 | async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response, sendNotFound = true) { |
19 | const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain) | 19 | const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain) |
20 | 20 | ||
21 | return processVideoChannelExist(videoChannel, res) | 21 | return processVideoChannelExist(videoChannel, res, sendNotFound) |
22 | } | 22 | } |
23 | 23 | ||
24 | // --------------------------------------------------------------------------- | 24 | // --------------------------------------------------------------------------- |
@@ -29,10 +29,12 @@ export { | |||
29 | doesVideoChannelNameWithHostExist | 29 | doesVideoChannelNameWithHostExist |
30 | } | 30 | } |
31 | 31 | ||
32 | function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response) { | 32 | function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response, sendNotFound = true) { |
33 | if (!videoChannel) { | 33 | if (!videoChannel) { |
34 | res.status(HttpStatusCode.NOT_FOUND_404) | 34 | if (sendNotFound) { |
35 | .json({ error: 'Video channel not found' }) | 35 | res.status(HttpStatusCode.NOT_FOUND_404) |
36 | .json({ error: 'Video channel not found' }) | ||
37 | } | ||
36 | 38 | ||
37 | return false | 39 | return false |
38 | } | 40 | } |