]>
Commit | Line | Data |
---|---|---|
41fb13c3 | 1 | import express from 'express' |
10363c74 | 2 | import { VideoChannelModel } from '@server/models/video/video-channel' |
2cb03dc1 | 3 | import { MChannelBannerAccountDefault } from '@server/types/models' |
c0e8b12e | 4 | import { HttpStatusCode } from '@shared/models' |
3e753302 | 5 | |
012580d9 | 6 | async function doesVideoChannelIdExist (id: number, res: express.Response) { |
453e83ea | 7 | const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id) |
3e753302 | 8 | |
012580d9 | 9 | return processVideoChannelExist(videoChannel, res) |
453e83ea C |
10 | } |
11 | ||
012580d9 | 12 | async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) { |
453e83ea C |
13 | const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain) |
14 | ||
012580d9 | 15 | return processVideoChannelExist(videoChannel, res) |
3e753302 C |
16 | } |
17 | ||
18 | // --------------------------------------------------------------------------- | |
19 | ||
20 | export { | |
453e83ea C |
21 | doesVideoChannelIdExist, |
22 | doesVideoChannelNameWithHostExist | |
23 | } | |
24 | ||
012580d9 | 25 | function processVideoChannelExist (videoChannel: MChannelBannerAccountDefault, res: express.Response) { |
453e83ea | 26 | if (!videoChannel) { |
76148b27 RK |
27 | res.fail({ |
28 | status: HttpStatusCode.NOT_FOUND_404, | |
29 | message: 'Video channel not found' | |
30 | }) | |
453e83ea C |
31 | return false |
32 | } | |
33 | ||
34 | res.locals.videoChannel = videoChannel | |
35 | return true | |
3e753302 | 36 | } |