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:
parent
a6ce68673a
commit
eacb25c436
24 changed files with 215 additions and 44 deletions
|
@ -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()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue