aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-08 17:36:10 +0200
committerChocobozzz <me@florianbigard.com>2018-08-08 17:44:22 +0200
commiteacb25c4366bcc8fba20f98f93f004fabc6d5578 (patch)
treed006c6ef3358ec8c3e3deda643dc9b70068f2515 /server/controllers
parenta6ce68673ace5b94a81eda3ba198f0a4170eb05e (diff)
downloadPeerTube-eacb25c4366bcc8fba20f98f93f004fabc6d5578.tar.gz
PeerTube-eacb25c4366bcc8fba20f98f93f004fabc6d5578.tar.zst
PeerTube-eacb25c4366bcc8fba20f98f93f004fabc6d5578.zip
Add reason when banning a user
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/users.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index 8f429d0b5..0e2be7123 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -302,8 +302,9 @@ async function unblockUser (req: express.Request, res: express.Response, next: e
302 302
303async function blockUser (req: express.Request, res: express.Response, next: express.NextFunction) { 303async function blockUser (req: express.Request, res: express.Response, next: express.NextFunction) {
304 const user: UserModel = res.locals.user 304 const user: UserModel = res.locals.user
305 const reason = req.body.reason
305 306
306 await changeUserBlock(res, user, true) 307 await changeUserBlock(res, user, true, reason)
307 308
308 return res.status(204).end() 309 return res.status(204).end()
309} 310}
@@ -454,10 +455,11 @@ function success (req: express.Request, res: express.Response, next: express.Nex
454 res.end() 455 res.end()
455} 456}
456 457
457async function changeUserBlock (res: express.Response, user: UserModel, block: boolean) { 458async function changeUserBlock (res: express.Response, user: UserModel, block: boolean, reason?: string) {
458 const oldUserAuditView = new UserAuditView(user.toFormattedJSON()) 459 const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
459 460
460 user.blocked = block 461 user.blocked = block
462 user.blockedReason = reason || null
461 463
462 await sequelizeTypescript.transaction(async t => { 464 await sequelizeTypescript.transaction(async t => {
463 await OAuthTokenModel.deleteUserToken(user.id, t) 465 await OAuthTokenModel.deleteUserToken(user.id, t)
@@ -465,6 +467,8 @@ async function changeUserBlock (res: express.Response, user: UserModel, block: b
465 await user.save({ transaction: t }) 467 await user.save({ transaction: t })
466 }) 468 })
467 469
470 await Emailer.Instance.addUserBlockJob(user, block, reason)
471
468 auditLogger.update( 472 auditLogger.update(
469 res.locals.oauth.token.User.Account.Actor.getIdentifier(), 473 res.locals.oauth.token.User.Account.Actor.getIdentifier(),
470 new UserAuditView(user.toFormattedJSON()), 474 new UserAuditView(user.toFormattedJSON()),