aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/middlewares
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
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')
-rw-r--r--server/helpers/middlewares/abuses.ts (renamed from server/helpers/middlewares/video-abuses.ts)18
-rw-r--r--server/helpers/middlewares/index.ts2
2 files changed, 13 insertions, 7 deletions
diff --git a/server/helpers/middlewares/video-abuses.ts b/server/helpers/middlewares/abuses.ts
index 97a5724b6..3906f6760 100644
--- a/server/helpers/middlewares/video-abuses.ts
+++ b/server/helpers/middlewares/abuses.ts
@@ -1,19 +1,20 @@
1import { Response } from 'express' 1import { Response } from 'express'
2import { VideoAbuseModel } from '../../models/video/video-abuse' 2import { AbuseModel } from '../../models/abuse/abuse'
3import { fetchVideo } from '../video' 3import { fetchVideo } from '../video'
4 4
5// FIXME: deprecated in 2.3. Remove this function
5async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) { 6async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) {
6 const abuseId = parseInt(abuseIdArg + '', 10) 7 const abuseId = parseInt(abuseIdArg + '', 10)
7 let videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID) 8 let abuse = await AbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID)
8 9
9 if (!videoAbuse) { 10 if (!abuse) {
10 const userId = res.locals.oauth?.token.User.id 11 const userId = res.locals.oauth?.token.User.id
11 const video = await fetchVideo(videoUUID, 'all', userId) 12 const video = await fetchVideo(videoUUID, 'all', userId)
12 13
13 if (video) videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, video.id) 14 if (video) abuse = await AbuseModel.loadByIdAndVideoId(abuseId, video.id)
14 } 15 }
15 16
16 if (videoAbuse === null) { 17 if (abuse === null) {
17 res.status(404) 18 res.status(404)
18 .json({ error: 'Video abuse not found' }) 19 .json({ error: 'Video abuse not found' })
19 .end() 20 .end()
@@ -21,12 +22,17 @@ async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: stri
21 return false 22 return false
22 } 23 }
23 24
24 res.locals.videoAbuse = videoAbuse 25 res.locals.abuse = abuse
25 return true 26 return true
26} 27}
27 28
29async function doesAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) {
30
31}
32
28// --------------------------------------------------------------------------- 33// ---------------------------------------------------------------------------
29 34
30export { 35export {
36 doesAbuseExist,
31 doesVideoAbuseExist 37 doesVideoAbuseExist
32} 38}
diff --git a/server/helpers/middlewares/index.ts b/server/helpers/middlewares/index.ts
index f91aeaa12..f57f3ad31 100644
--- a/server/helpers/middlewares/index.ts
+++ b/server/helpers/middlewares/index.ts
@@ -1,5 +1,5 @@
1export * from './abuses'
1export * from './accounts' 2export * from './accounts'
2export * from './video-abuses'
3export * from './video-blacklists' 3export * from './video-blacklists'
4export * from './video-captions' 4export * from './video-captions'
5export * from './video-channels' 5export * from './video-channels'