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.ts11
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { UserRight, VideoAbuseCreate, VideoAbuseState, VideoAbuse } from '../../../../shared' 2import { UserRight, VideoAbuseCreate, VideoAbuseState, VideoAbuse, videoAbusePredefinedReasonsMap } from '../../../../shared'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { getFormattedObjects } from '../../../helpers/utils' 4import { getFormattedObjects } from '../../../helpers/utils'
5import { sequelizeTypescript } from '../../../initializers/database' 5import { 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}