1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Add reason when banning a user

This commit is contained in:
Chocobozzz 2018-08-08 17:36:10 +02:00
parent a6ce68673a
commit eacb25c436
No known key found for this signature in database
GPG key ID: 583A612D890159BE
24 changed files with 215 additions and 44 deletions

View file

@ -302,8 +302,9 @@ async function unblockUser (req: express.Request, res: express.Response, next: e
async function blockUser (req: express.Request, res: express.Response, next: express.NextFunction) {
const user: UserModel = res.locals.user
const reason = req.body.reason
await changeUserBlock(res, user, true)
await changeUserBlock(res, user, true, reason)
return res.status(204).end()
}
@ -454,10 +455,11 @@ function success (req: express.Request, res: express.Response, next: express.Nex
res.end()
}
async function changeUserBlock (res: express.Response, user: UserModel, block: boolean) {
async function changeUserBlock (res: express.Response, user: UserModel, block: boolean, reason?: string) {
const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
user.blocked = block
user.blockedReason = reason || null
await sequelizeTypescript.transaction(async t => {
await OAuthTokenModel.deleteUserToken(user.id, t)
@ -465,6 +467,8 @@ async function changeUserBlock (res: express.Response, user: UserModel, block: b
await user.save({ transaction: t })
})
await Emailer.Instance.addUserBlockJob(user, block, reason)
auditLogger.update(
res.locals.oauth.token.User.Account.Actor.getIdentifier(),
new UserAuditView(user.toFormattedJSON()),