1 import { Response } from 'express'
2 import { AbuseModel } from '../../models/abuse/abuse'
3 import { fetchVideo } from '../video'
5 // FIXME: deprecated in 2.3. Remove this function
6 async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) {
7 const abuseId = parseInt(abuseIdArg + '', 10)
8 let abuse = await AbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID)
11 const userId = res.locals.oauth?.token.User.id
12 const video = await fetchVideo(videoUUID, 'all', userId)
14 if (video) abuse = await AbuseModel.loadByIdAndVideoId(abuseId, video.id)
19 .json({ error: 'Video abuse not found' })
24 res.locals.abuse = abuse
28 async function doesAbuseExist (abuseId: number | string, res: Response) {
29 const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
33 .json({ error: 'Abuse not found' })
38 res.locals.abuse = abuse
42 // ---------------------------------------------------------------------------