aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/middlewares/video-abuses.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-07-01 16:05:30 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-07-10 14:02:41 +0200
commitd95d15598847c7f020aa056e7e6e0c02d2bbf732 (patch)
treea8a593f1269688caf9e5f99559996f346290fec5 /server/helpers/middlewares/video-abuses.ts
parent72493e44e9b455a04c4f093ed6c6ffa300b98d8b (diff)
downloadPeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.tar.gz
PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.tar.zst
PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.zip
Use 3 tables to represent abuses
Diffstat (limited to 'server/helpers/middlewares/video-abuses.ts')
-rw-r--r--server/helpers/middlewares/video-abuses.ts32
1 files changed, 0 insertions, 32 deletions
diff --git a/server/helpers/middlewares/video-abuses.ts b/server/helpers/middlewares/video-abuses.ts
deleted file mode 100644
index 97a5724b6..000000000
--- a/server/helpers/middlewares/video-abuses.ts
+++ /dev/null
@@ -1,32 +0,0 @@
1import { Response } from 'express'
2import { VideoAbuseModel } from '../../models/video/video-abuse'
3import { fetchVideo } from '../video'
4
5async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) {
6 const abuseId = parseInt(abuseIdArg + '', 10)
7 let videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID)
8
9 if (!videoAbuse) {
10 const userId = res.locals.oauth?.token.User.id
11 const video = await fetchVideo(videoUUID, 'all', userId)
12
13 if (video) videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, video.id)
14 }
15
16 if (videoAbuse === null) {
17 res.status(404)
18 .json({ error: 'Video abuse not found' })
19 .end()
20
21 return false
22 }
23
24 res.locals.videoAbuse = videoAbuse
25 return true
26}
27
28// ---------------------------------------------------------------------------
29
30export {
31 doesVideoAbuseExist
32}