aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/abuse.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos/abuse.ts')
-rw-r--r--server/controllers/api/videos/abuse.ts114
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 @@
1import * as express from 'express'
2import { AbuseModel } from '@server/models/abuse/abuse'
3import { getServerActor } from '@server/models/application/application'
4import { AbuseCreate, UserRight, VideoAbuseCreate } from '../../../../shared'
5import {
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'
19import { deleteAbuse, reportAbuse, updateAbuse } from '../abuse'
20
21// FIXME: deprecated in 2.3. Remove this controller
22
23const abuseVideoRouter = express.Router()
24
25abuseVideoRouter.get('/abuse',
26 authenticate,
27 ensureUserHasRight(UserRight.MANAGE_ABUSES),
28 paginationValidator,
29 abusesSortValidator,
30 setDefaultSort,
31 setDefaultPagination,
32 videoAbuseListValidator,
33 asyncMiddleware(listVideoAbuses)
34)
35abuseVideoRouter.put('/:videoId/abuse/:id',
36 authenticate,
37 ensureUserHasRight(UserRight.MANAGE_ABUSES),
38 asyncMiddleware(videoAbuseUpdateValidator),
39 asyncRetryTransactionMiddleware(updateVideoAbuse)
40)
41abuseVideoRouter.post('/:videoId/abuse',
42 authenticate,
43 asyncMiddleware(videoAbuseReportValidator),
44 asyncRetryTransactionMiddleware(reportVideoAbuse)
45)
46abuseVideoRouter.delete('/:videoId/abuse/:id',
47 authenticate,
48 ensureUserHasRight(UserRight.MANAGE_ABUSES),
49 asyncMiddleware(videoAbuseGetValidator),
50 asyncRetryTransactionMiddleware(deleteVideoAbuse)
51)
52
53// ---------------------------------------------------------------------------
54
55export {
56 abuseVideoRouter
57}
58
59// ---------------------------------------------------------------------------
60
61async 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
89async function updateVideoAbuse (req: express.Request, res: express.Response) {
90 return updateAbuse(req, res)
91}
92
93async function deleteVideoAbuse (req: express.Request, res: express.Response) {
94 return deleteAbuse(req, res)
95}
96
97async 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}