aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-04-16 14:22:27 +0200
committerRigel Kent <par@rigelk.eu>2020-05-01 16:41:02 +0200
commit68d19a0ace01cb7a3550da420d27663e2db1b98d (patch)
treefcdac5341001b9e6d15ddd0ca8239372ec2b3053 /server/helpers
parent165ee2929bc76fc7f9985ae81cc33736820c7865 (diff)
downloadPeerTube-68d19a0ace01cb7a3550da420d27663e2db1b98d.tar.gz
PeerTube-68d19a0ace01cb7a3550da420d27663e2db1b98d.tar.zst
PeerTube-68d19a0ace01cb7a3550da420d27663e2db1b98d.zip
Make sure a report doesn't get deleted upon the deletion of its video
Diffstat (limited to 'server/helpers')
-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)