diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-10 14:41:20 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-11-10 14:50:16 +0100 |
commit | 7a4ea932461f228ae44a173ddcd48ffb088aa023 (patch) | |
tree | 429b6fa7dae496d339a9f22e4076e39ffda97461 /server/helpers | |
parent | 403c69c5a34e6db621f30c7b2bfb2b80dc8e74c1 (diff) | |
download | PeerTube-7a4ea932461f228ae44a173ddcd48ffb088aa023.tar.gz PeerTube-7a4ea932461f228ae44a173ddcd48ffb088aa023.tar.zst PeerTube-7a4ea932461f228ae44a173ddcd48ffb088aa023.zip |
Remove deprecated abuse api
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/middlewares/abuses.ts | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/server/helpers/middlewares/abuses.ts b/server/helpers/middlewares/abuses.ts index 659ad8939..59ba0d3ed 100644 --- a/server/helpers/middlewares/abuses.ts +++ b/server/helpers/middlewares/abuses.ts | |||
@@ -1,29 +1,5 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import { AbuseModel } from '../../models/abuse/abuse' | 2 | import { AbuseModel } from '../../models/abuse/abuse' |
3 | import { fetchVideo } from '../video' | ||
4 | |||
5 | // FIXME: deprecated in 2.3. Remove this function | ||
6 | async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: string, res: Response) { | ||
7 | const abuseId = parseInt(abuseIdArg + '', 10) | ||
8 | let abuse = await AbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID) | ||
9 | |||
10 | if (!abuse) { | ||
11 | const userId = res.locals.oauth?.token.User.id | ||
12 | const video = await fetchVideo(videoUUID, 'all', userId) | ||
13 | |||
14 | if (video) abuse = await AbuseModel.loadByIdAndVideoId(abuseId, video.id) | ||
15 | } | ||
16 | |||
17 | if (abuse === null) { | ||
18 | res.status(404) | ||
19 | .json({ error: 'Video abuse not found' }) | ||
20 | |||
21 | return false | ||
22 | } | ||
23 | |||
24 | res.locals.abuse = abuse | ||
25 | return true | ||
26 | } | ||
27 | 3 | ||
28 | async function doesAbuseExist (abuseId: number | string, res: Response) { | 4 | async function doesAbuseExist (abuseId: number | string, res: Response) { |
29 | const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10)) | 5 | const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10)) |
@@ -42,6 +18,5 @@ async function doesAbuseExist (abuseId: number | string, res: Response) { | |||
42 | // --------------------------------------------------------------------------- | 18 | // --------------------------------------------------------------------------- |
43 | 19 | ||
44 | export { | 20 | export { |
45 | doesAbuseExist, | 21 | doesAbuseExist |
46 | doesVideoAbuseExist | ||
47 | } | 22 | } |