-import * as express from 'express'
-import { VideoChannelModel } from '../../models/video/video-channel'
+import { Response } from 'express'
+import { VideoAbuseModel } from '../../models/video/video-abuse'
-async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
- const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
+async function doesVideoAbuseExist (abuseIdArg: number | string, videoId: number, res: Response) {
+ const abuseId = parseInt(abuseIdArg + '', 10)
+ const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId)
- return processVideoChannelExist(videoChannel, res)
-}
-
-async function doesVideoChannelIdExist (id: number, res: express.Response) {
- const videoChannel = await VideoChannelModel.loadAndPopulateAccount(+id)
-
- return processVideoChannelExist(videoChannel, res)
-}
-
-async function doesVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) {
- const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain)
-
- return processVideoChannelExist(videoChannel, res)
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- doesLocalVideoChannelNameExist,
- doesVideoChannelIdExist,
- doesVideoChannelNameWithHostExist
-}
-
-function processVideoChannelExist (videoChannel: VideoChannelModel, res: express.Response) {
- if (!videoChannel) {
+ if (videoAbuse === null) {
res.status(404)
- .json({ error: 'Video channel not found' })
+ .json({ error: 'Video abuse not found' })
.end()
return false
}
- res.locals.videoChannel = videoChannel
+ res.locals.videoAbuse = videoAbuse
return true
}
+
+// ---------------------------------------------------------------------------
+
+export {
+ doesVideoAbuseExist
+}