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