diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-06-22 13:00:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 13:00:39 +0200 |
commit | 1ebddadd0704812a4600c39cabe2268321e88331 (patch) | |
tree | 1cc8560e5b63e9976aa5411ba800a62cfe7b8ea9 /server/controllers/api/videos/abuse.ts | |
parent | 07aea1a2642fc9868cb01e30c322514029d5b95a (diff) | |
download | PeerTube-1ebddadd0704812a4600c39cabe2268321e88331.tar.gz PeerTube-1ebddadd0704812a4600c39cabe2268321e88331.tar.zst PeerTube-1ebddadd0704812a4600c39cabe2268321e88331.zip |
predefined report reasons & improved reporter UI (#2842)
- added `startAt` and `endAt` optional timestamps to help pin down reported sections of a video
- added predefined report reasons
- added video player with report modal
Diffstat (limited to 'server/controllers/api/videos/abuse.ts')
-rw-r--r-- | server/controllers/api/videos/abuse.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts index 77843f149..ab2074459 100644 --- a/server/controllers/api/videos/abuse.ts +++ b/server/controllers/api/videos/abuse.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { UserRight, VideoAbuseCreate, VideoAbuseState, VideoAbuse } from '../../../../shared' | 2 | import { UserRight, VideoAbuseCreate, VideoAbuseState, VideoAbuse, videoAbusePredefinedReasonsMap } from '../../../../shared' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { getFormattedObjects } from '../../../helpers/utils' | 4 | import { getFormattedObjects } from '../../../helpers/utils' |
5 | import { sequelizeTypescript } from '../../../initializers/database' | 5 | import { sequelizeTypescript } from '../../../initializers/database' |
@@ -74,6 +74,7 @@ async function listVideoAbuses (req: express.Request, res: express.Response) { | |||
74 | count: req.query.count, | 74 | count: req.query.count, |
75 | sort: req.query.sort, | 75 | sort: req.query.sort, |
76 | id: req.query.id, | 76 | id: req.query.id, |
77 | predefinedReason: req.query.predefinedReason, | ||
77 | search: req.query.search, | 78 | search: req.query.search, |
78 | state: req.query.state, | 79 | state: req.query.state, |
79 | videoIs: req.query.videoIs, | 80 | videoIs: req.query.videoIs, |
@@ -123,12 +124,16 @@ async function reportVideoAbuse (req: express.Request, res: express.Response) { | |||
123 | 124 | ||
124 | const videoAbuseInstance = await sequelizeTypescript.transaction(async t => { | 125 | const videoAbuseInstance = await sequelizeTypescript.transaction(async t => { |
125 | reporterAccount = await AccountModel.load(res.locals.oauth.token.User.Account.id, t) | 126 | reporterAccount = await AccountModel.load(res.locals.oauth.token.User.Account.id, t) |
127 | const predefinedReasons = body.predefinedReasons?.map(r => videoAbusePredefinedReasonsMap[r]) | ||
126 | 128 | ||
127 | const abuseToCreate = { | 129 | const abuseToCreate = { |
128 | reporterAccountId: reporterAccount.id, | 130 | reporterAccountId: reporterAccount.id, |
129 | reason: body.reason, | 131 | reason: body.reason, |
130 | videoId: videoInstance.id, | 132 | videoId: videoInstance.id, |
131 | state: VideoAbuseState.PENDING | 133 | state: VideoAbuseState.PENDING, |
134 | predefinedReasons, | ||
135 | startAt: body.startAt, | ||
136 | endAt: body.endAt | ||
132 | } | 137 | } |
133 | 138 | ||
134 | const videoAbuseInstance: MVideoAbuseAccountVideo = await VideoAbuseModel.create(abuseToCreate, { transaction: t }) | 139 | const videoAbuseInstance: MVideoAbuseAccountVideo = await VideoAbuseModel.create(abuseToCreate, { transaction: t }) |
@@ -152,7 +157,7 @@ async function reportVideoAbuse (req: express.Request, res: express.Response) { | |||
152 | reporter: reporterAccount.Actor.getIdentifier() | 157 | reporter: reporterAccount.Actor.getIdentifier() |
153 | }) | 158 | }) |
154 | 159 | ||
155 | logger.info('Abuse report for video %s created.', videoInstance.name) | 160 | logger.info('Abuse report for video "%s" created.', videoInstance.name) |
156 | 161 | ||
157 | return res.json({ videoAbuse: videoAbuseJSON }).end() | 162 | return res.json({ videoAbuse: videoAbuseJSON }).end() |
158 | } | 163 | } |