aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/middlewares/video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/middlewares/video-channels.ts')
-rw-r--r--server/helpers/middlewares/video-channels.ts20
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'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
4import { VideoChannelModel } from '../../models/video/video-channel' 4import { VideoChannelModel } from '../../models/video/video-channel'
5 5
6async function doesLocalVideoChannelNameExist (name: string, res: express.Response) { 6async 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
12async function doesVideoChannelIdExist (id: number, res: express.Response) { 12async 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
18async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) { 18async 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
32function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response) { 32function 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 }