diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/abuse.ts | 8 | ||||
-rw-r--r-- | server/controllers/api/videos/abuse.ts | 114 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 4 |
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 | ||
87 | export { | 87 | export { |
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 @@ | |||
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 | } | ||
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' | |||
6 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 6 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
7 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' | 7 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' |
8 | import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' | 8 | import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' |
9 | import { LiveManager } from '@server/lib/live-manager' | ||
9 | import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' | 10 | import { buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' |
10 | import { getVideoFilePath } from '@server/lib/video-paths' | 11 | import { getVideoFilePath } from '@server/lib/video-paths' |
11 | import { getServerActor } from '@server/models/application/application' | 12 | import { getServerActor } from '@server/models/application/application' |
@@ -57,7 +58,6 @@ import { | |||
57 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | 58 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' |
58 | import { VideoModel } from '../../../models/video/video' | 59 | import { VideoModel } from '../../../models/video/video' |
59 | import { VideoFileModel } from '../../../models/video/video-file' | 60 | import { VideoFileModel } from '../../../models/video/video-file' |
60 | import { abuseVideoRouter } from './abuse' | ||
61 | import { blacklistRouter } from './blacklist' | 61 | import { blacklistRouter } from './blacklist' |
62 | import { videoCaptionsRouter } from './captions' | 62 | import { videoCaptionsRouter } from './captions' |
63 | import { videoCommentRouter } from './comment' | 63 | import { videoCommentRouter } from './comment' |
@@ -66,7 +66,6 @@ import { liveRouter } from './live' | |||
66 | import { ownershipVideoRouter } from './ownership' | 66 | import { ownershipVideoRouter } from './ownership' |
67 | import { rateVideoRouter } from './rate' | 67 | import { rateVideoRouter } from './rate' |
68 | import { watchingRouter } from './watching' | 68 | import { watchingRouter } from './watching' |
69 | import { LiveManager } from '@server/lib/live-manager' | ||
70 | 69 | ||
71 | const auditLogger = auditLoggerFactory('videos') | 70 | const auditLogger = auditLoggerFactory('videos') |
72 | const videosRouter = express.Router() | 71 | const videosRouter = express.Router() |
@@ -89,7 +88,6 @@ const reqVideoFileUpdate = createReqFiles( | |||
89 | } | 88 | } |
90 | ) | 89 | ) |
91 | 90 | ||
92 | videosRouter.use('/', abuseVideoRouter) | ||
93 | videosRouter.use('/', blacklistRouter) | 91 | videosRouter.use('/', blacklistRouter) |
94 | videosRouter.use('/', rateVideoRouter) | 92 | videosRouter.use('/', rateVideoRouter) |
95 | videosRouter.use('/', videoCommentRouter) | 93 | videosRouter.use('/', videoCommentRouter) |