aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/abuse.ts8
-rw-r--r--server/controllers/api/videos/abuse.ts114
-rw-r--r--server/controllers/api/videos/index.ts4
3 files changed, 2 insertions, 124 deletions
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts
index b97b99f16..25d6e2ab0 100644
--- a/server/controllers/api/abuse.ts
+++ b/server/controllers/api/abuse.ts
@@ -85,13 +85,7 @@ abuseRouter.delete('/:id/messages/:messageId',
85// --------------------------------------------------------------------------- 85// ---------------------------------------------------------------------------
86 86
87export { 87export {
88 abuseRouter, 88 abuseRouter
89
90 // FIXME: deprecated in 2.3. Remove these exports
91 listAbusesForAdmins,
92 updateAbuse,
93 deleteAbuse,
94 reportAbuse
95} 89}
96 90
97// --------------------------------------------------------------------------- 91// ---------------------------------------------------------------------------
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}
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 3f96f142c..bfebc54ed 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -6,6 +6,7 @@ import { addOptimizeOrMergeAudioJob } from '@server/helpers/video'
6import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 6import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
7import { changeVideoChannelShare } from '@server/lib/activitypub/share' 7import { changeVideoChannelShare } from '@server/lib/activitypub/share'
8import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' 8import { getVideoActivityPubUrl } from '@server/lib/activitypub/url'
9import { LiveManager } from '@server/lib/live-manager'
9import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' 10import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
10import { getVideoFilePath } from '@server/lib/video-paths' 11import { getVideoFilePath } from '@server/lib/video-paths'
11import { getServerActor } from '@server/models/application/application' 12import { getServerActor } from '@server/models/application/application'
@@ -57,7 +58,6 @@ import {
57import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' 58import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
58import { VideoModel } from '../../../models/video/video' 59import { VideoModel } from '../../../models/video/video'
59import { VideoFileModel } from '../../../models/video/video-file' 60import { VideoFileModel } from '../../../models/video/video-file'
60import { abuseVideoRouter } from './abuse'
61import { blacklistRouter } from './blacklist' 61import { blacklistRouter } from './blacklist'
62import { videoCaptionsRouter } from './captions' 62import { videoCaptionsRouter } from './captions'
63import { videoCommentRouter } from './comment' 63import { videoCommentRouter } from './comment'
@@ -66,7 +66,6 @@ import { liveRouter } from './live'
66import { ownershipVideoRouter } from './ownership' 66import { ownershipVideoRouter } from './ownership'
67import { rateVideoRouter } from './rate' 67import { rateVideoRouter } from './rate'
68import { watchingRouter } from './watching' 68import { watchingRouter } from './watching'
69import { LiveManager } from '@server/lib/live-manager'
70 69
71const auditLogger = auditLoggerFactory('videos') 70const auditLogger = auditLoggerFactory('videos')
72const videosRouter = express.Router() 71const videosRouter = express.Router()
@@ -89,7 +88,6 @@ const reqVideoFileUpdate = createReqFiles(
89 } 88 }
90) 89)
91 90
92videosRouter.use('/', abuseVideoRouter)
93videosRouter.use('/', blacklistRouter) 91videosRouter.use('/', blacklistRouter)
94videosRouter.use('/', rateVideoRouter) 92videosRouter.use('/', rateVideoRouter)
95videosRouter.use('/', videoCommentRouter) 93videosRouter.use('/', videoCommentRouter)