aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/middlewares/video-abuses.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/middlewares/video-abuses.ts')
-rw-r--r--server/helpers/middlewares/video-abuses.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/server/helpers/middlewares/video-abuses.ts b/server/helpers/middlewares/video-abuses.ts
index 8a1d3d618..7553a5eb3 100644
--- a/server/helpers/middlewares/video-abuses.ts
+++ b/server/helpers/middlewares/video-abuses.ts
@@ -1,9 +1,17 @@
1import { Response } from 'express' 1import { Response } from 'express'
2import { VideoAbuseModel } from '../../models/video/video-abuse' 2import { VideoAbuseModel } from '../../models/video/video-abuse'
3import { fetchVideo } from '../video'
3 4
4async function doesVideoAbuseExist (abuseIdArg: number | string, videoId: number, res: Response) { 5async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) {
5 const abuseId = parseInt(abuseIdArg + '', 10) 6 const abuseId = parseInt(abuseIdArg + '', 10)
6 const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId) 7 let videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID)
8
9 if (!videoAbuse) {
10 const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined
11 const video = await fetchVideo(videoUUID, 'all', userId)
12
13 if (video) videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, video.id)
14 }
7 15
8 if (videoAbuse === null) { 16 if (videoAbuse === null) {
9 res.status(404) 17 res.status(404)