aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-05-05 20:22:22 +0200
committerRigel Kent <par@rigelk.eu>2020-05-08 15:31:51 +0200
commitdf4c603dea022146476812cbbc2b9f8f1e5e4870 (patch)
treec0d27576fb6711b4b64d2186e8dca3f04b9b1dfe /server/controllers
parent91b8e675e26dd65e1ebb23706cb16b3a3f8bcf73 (diff)
downloadPeerTube-df4c603dea022146476812cbbc2b9f8f1e5e4870.tar.gz
PeerTube-df4c603dea022146476812cbbc2b9f8f1e5e4870.tar.zst
PeerTube-df4c603dea022146476812cbbc2b9f8f1e5e4870.zip
Switch emails to pug templates and provide richer html/text-only versions
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/videos/abuse.ts20
1 files changed, 14 insertions, 6 deletions
diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts
index bce50aefb..ec28fce67 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 } from '../../../../shared' 2import { UserRight, VideoAbuseCreate, VideoAbuseState, VideoAbuse } 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'
@@ -24,6 +24,7 @@ import { Notifier } from '../../../lib/notifier'
24import { sendVideoAbuse } from '../../../lib/activitypub/send/send-flag' 24import { sendVideoAbuse } from '../../../lib/activitypub/send/send-flag'
25import { MVideoAbuseAccountVideo } from '../../../typings/models/video' 25import { MVideoAbuseAccountVideo } from '../../../typings/models/video'
26import { getServerActor } from '@server/models/application/application' 26import { getServerActor } from '@server/models/application/application'
27import { MAccountDefault } from '@server/typings/models'
27 28
28const auditLogger = auditLoggerFactory('abuse') 29const auditLogger = auditLoggerFactory('abuse')
29const abuseVideoRouter = express.Router() 30const abuseVideoRouter = express.Router()
@@ -117,9 +118,11 @@ async function deleteVideoAbuse (req: express.Request, res: express.Response) {
117async function reportVideoAbuse (req: express.Request, res: express.Response) { 118async function reportVideoAbuse (req: express.Request, res: express.Response) {
118 const videoInstance = res.locals.videoAll 119 const videoInstance = res.locals.videoAll
119 const body: VideoAbuseCreate = req.body 120 const body: VideoAbuseCreate = req.body
121 let reporterAccount: MAccountDefault
122 let videoAbuseJSON: VideoAbuse
120 123
121 const videoAbuse = await sequelizeTypescript.transaction(async t => { 124 const videoAbuseInstance = await sequelizeTypescript.transaction(async t => {
122 const reporterAccount = await AccountModel.load(res.locals.oauth.token.User.Account.id, t) 125 reporterAccount = await AccountModel.load(res.locals.oauth.token.User.Account.id, t)
123 126
124 const abuseToCreate = { 127 const abuseToCreate = {
125 reporterAccountId: reporterAccount.id, 128 reporterAccountId: reporterAccount.id,
@@ -137,14 +140,19 @@ async function reportVideoAbuse (req: express.Request, res: express.Response) {
137 await sendVideoAbuse(reporterAccount.Actor, videoAbuseInstance, videoInstance, t) 140 await sendVideoAbuse(reporterAccount.Actor, videoAbuseInstance, videoInstance, t)
138 } 141 }
139 142
140 auditLogger.create(reporterAccount.Actor.getIdentifier(), new VideoAbuseAuditView(videoAbuseInstance.toFormattedJSON())) 143 videoAbuseJSON = videoAbuseInstance.toFormattedJSON()
144 auditLogger.create(reporterAccount.Actor.getIdentifier(), new VideoAbuseAuditView(videoAbuseJSON))
141 145
142 return videoAbuseInstance 146 return videoAbuseInstance
143 }) 147 })
144 148
145 Notifier.Instance.notifyOnNewVideoAbuse(videoAbuse) 149 Notifier.Instance.notifyOnNewVideoAbuse({
150 videoAbuse: videoAbuseJSON,
151 videoAbuseInstance,
152 reporter: reporterAccount.Actor.getIdentifier()
153 })
146 154
147 logger.info('Abuse report for video %s created.', videoInstance.name) 155 logger.info('Abuse report for video %s created.', videoInstance.name)
148 156
149 return res.json({ videoAbuse: videoAbuse.toFormattedJSON() }).end() 157 return res.json({ videoAbuseJSON }).end()
150} 158}