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/controllers/api/videos/abuse.ts | |
parent | 403c69c5a34e6db621f30c7b2bfb2b80dc8e74c1 (diff) | |
download | PeerTube-7a4ea932461f228ae44a173ddcd48ffb088aa023.tar.gz PeerTube-7a4ea932461f228ae44a173ddcd48ffb088aa023.tar.zst PeerTube-7a4ea932461f228ae44a173ddcd48ffb088aa023.zip |
Remove deprecated abuse api
Diffstat (limited to 'server/controllers/api/videos/abuse.ts')
-rw-r--r-- | server/controllers/api/videos/abuse.ts | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts deleted file mode 100644 index 9c4d00849..000000000 --- a/server/controllers/api/videos/abuse.ts +++ /dev/null | |||
@@ -1,114 +0,0 @@ | |||
1 | import * as express from 'express' | ||
2 | import { AbuseModel } from '@server/models/abuse/abuse' | ||
3 | import { getServerActor } from '@server/models/application/application' | ||
4 | import { AbuseCreate, UserRight, VideoAbuseCreate } from '../../../../shared' | ||
5 | import { | ||
6 | abusesSortValidator, | ||
7 | asyncMiddleware, | ||
8 | asyncRetryTransactionMiddleware, | ||
9 | authenticate, | ||
10 | ensureUserHasRight, | ||
11 | paginationValidator, | ||
12 | setDefaultPagination, | ||
13 | setDefaultSort, | ||
14 | videoAbuseGetValidator, | ||
15 | videoAbuseListValidator, | ||
16 | videoAbuseReportValidator, | ||
17 | videoAbuseUpdateValidator | ||
18 | } from '../../../middlewares' | ||
19 | import { deleteAbuse, reportAbuse, updateAbuse } from '../abuse' | ||
20 | |||
21 | // FIXME: deprecated in 2.3. Remove this controller | ||
22 | |||
23 | const abuseVideoRouter = express.Router() | ||
24 | |||
25 | abuseVideoRouter.get('/abuse', | ||
26 | authenticate, | ||
27 | ensureUserHasRight(UserRight.MANAGE_ABUSES), | ||
28 | paginationValidator, | ||
29 | abusesSortValidator, | ||
30 | setDefaultSort, | ||
31 | setDefaultPagination, | ||
32 | videoAbuseListValidator, | ||
33 | asyncMiddleware(listVideoAbuses) | ||
34 | ) | ||
35 | abuseVideoRouter.put('/:videoId/abuse/:id', | ||
36 | authenticate, | ||
37 | ensureUserHasRight(UserRight.MANAGE_ABUSES), | ||
38 | asyncMiddleware(videoAbuseUpdateValidator), | ||
39 | asyncRetryTransactionMiddleware(updateVideoAbuse) | ||
40 | ) | ||
41 | abuseVideoRouter.post('/:videoId/abuse', | ||
42 | authenticate, | ||
43 | asyncMiddleware(videoAbuseReportValidator), | ||
44 | asyncRetryTransactionMiddleware(reportVideoAbuse) | ||
45 | ) | ||
46 | abuseVideoRouter.delete('/:videoId/abuse/:id', | ||
47 | authenticate, | ||
48 | ensureUserHasRight(UserRight.MANAGE_ABUSES), | ||
49 | asyncMiddleware(videoAbuseGetValidator), | ||
50 | asyncRetryTransactionMiddleware(deleteVideoAbuse) | ||
51 | ) | ||
52 | |||
53 | // --------------------------------------------------------------------------- | ||
54 | |||
55 | export { | ||
56 | abuseVideoRouter | ||
57 | } | ||
58 | |||
59 | // --------------------------------------------------------------------------- | ||
60 | |||
61 | async function listVideoAbuses (req: express.Request, res: express.Response) { | ||
62 | const user = res.locals.oauth.token.user | ||
63 | const serverActor = await getServerActor() | ||
64 | |||
65 | const resultList = await AbuseModel.listForAdminApi({ | ||
66 | start: req.query.start, | ||
67 | count: req.query.count, | ||
68 | sort: req.query.sort, | ||
69 | id: req.query.id, | ||
70 | filter: 'video', | ||
71 | predefinedReason: req.query.predefinedReason, | ||
72 | search: req.query.search, | ||
73 | state: req.query.state, | ||
74 | videoIs: req.query.videoIs, | ||
75 | searchReporter: req.query.searchReporter, | ||
76 | searchReportee: req.query.searchReportee, | ||
77 | searchVideo: req.query.searchVideo, | ||
78 | searchVideoChannel: req.query.searchVideoChannel, | ||
79 | serverAccountId: serverActor.Account.id, | ||
80 | user | ||
81 | }) | ||
82 | |||
83 | return res.json({ | ||
84 | total: resultList.total, | ||
85 | data: resultList.data.map(d => d.toFormattedAdminJSON()) | ||
86 | }) | ||
87 | } | ||
88 | |||
89 | async function updateVideoAbuse (req: express.Request, res: express.Response) { | ||
90 | return updateAbuse(req, res) | ||
91 | } | ||
92 | |||
93 | async function deleteVideoAbuse (req: express.Request, res: express.Response) { | ||
94 | return deleteAbuse(req, res) | ||
95 | } | ||
96 | |||
97 | async function reportVideoAbuse (req: express.Request, res: express.Response) { | ||
98 | const oldBody = req.body as VideoAbuseCreate | ||
99 | |||
100 | req.body = { | ||
101 | accountId: res.locals.videoAll.VideoChannel.accountId, | ||
102 | |||
103 | reason: oldBody.reason, | ||
104 | predefinedReasons: oldBody.predefinedReasons, | ||
105 | |||
106 | video: { | ||
107 | id: res.locals.videoAll.id, | ||
108 | startAt: oldBody.startAt, | ||
109 | endAt: oldBody.endAt | ||
110 | } | ||
111 | } as AbuseCreate | ||
112 | |||
113 | return reportAbuse(req, res) | ||
114 | } | ||