diff options
Diffstat (limited to 'server/controllers/api/users.ts')
-rw-r--r-- | server/controllers/api/users.ts | 8 |
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 | ||
303 | async function blockUser (req: express.Request, res: express.Response, next: express.NextFunction) { | 303 | async 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 | ||
457 | async function changeUserBlock (res: express.Response, user: UserModel, block: boolean) { | 458 | async 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()), |