1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00

Add abuse and registration requests stats

This commit is contained in:
Chocobozzz 2024-02-21 13:48:52 +01:00
parent fbe47a9f8e
commit db69d9491e
No known key found for this signature in database
GPG key ID: 583A612D890159BE
25 changed files with 638 additions and 227 deletions

View file

@ -131,6 +131,10 @@ async function updateAbuse (req: express.Request, res: express.Response) {
if (req.body.state !== undefined) {
abuse.state = req.body.state
// We consider the abuse has been processed when its state change
if (!abuse.processedAt) abuse.processedAt = new Date()
stateUpdated = true
}
@ -229,14 +233,21 @@ async function listAbuseMessages (req: express.Request, res: express.Response) {
async function addAbuseMessage (req: express.Request, res: express.Response) {
const abuse = res.locals.abuse
const user = res.locals.oauth.token.user
const byModerator = abuse.reporterAccountId !== user.Account.id
const abuseMessage = await AbuseMessageModel.create({
message: req.body.message,
byModerator: abuse.reporterAccountId !== user.Account.id,
byModerator,
accountId: user.Account.id,
abuseId: abuse.id
})
// If a moderator created an abuse message, we consider it as processed
if (byModerator && !abuse.processedAt) {
abuse.processedAt = new Date()
await abuse.save()
}
AbuseModel.loadFull(abuse.id)
.then(abuseFull => Notifier.Instance.notifyOnAbuseMessage(abuseFull, abuseMessage))
.catch(err => logger.error('Cannot notify on new abuse message', { err }))