diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-01 16:05:30 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-10 14:02:41 +0200 |
commit | d95d15598847c7f020aa056e7e6e0c02d2bbf732 (patch) | |
tree | a8a593f1269688caf9e5f99559996f346290fec5 /server/helpers/middlewares/video-abuses.ts | |
parent | 72493e44e9b455a04c4f093ed6c6ffa300b98d8b (diff) | |
download | PeerTube-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.ts | 32 |
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 @@ | |||
1 | import { Response } from 'express' | ||
2 | import { VideoAbuseModel } from '../../models/video/video-abuse' | ||
3 | import { fetchVideo } from '../video' | ||
4 | |||
5 | async 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 | |||
30 | export { | ||
31 | doesVideoAbuseExist | ||
32 | } | ||