mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Added mute end date (#10566)
* Added mute end date * Added indefinite mute for users using slurs * Fixed user reload. Added no longer muted message. Added format for date * Fixed lint
This commit is contained in:
@@ -12,6 +12,7 @@ import { getUserInfo, getGroupUrl, sendTxn } from '../../libs/email';
|
||||
import slack from '../../libs/slack';
|
||||
import pusher from '../../libs/pusher';
|
||||
import { getAuthorEmailFromMessage } from '../../libs/chat';
|
||||
import { userIsMuted, muteUserForLife } from '../../libs/chat/mute';
|
||||
import { chatReporterFactory } from '../../libs/chatReporting/chatReporterFactory';
|
||||
import nconf from 'nconf';
|
||||
import bannedWords from '../../libs/bannedWords';
|
||||
@@ -124,6 +125,7 @@ api.postChat = {
|
||||
if (textContainsBannedSlur(req.body.message)) {
|
||||
let message = req.body.message;
|
||||
user.flags.chatRevoked = true;
|
||||
muteUserForLife(user);
|
||||
await user.save();
|
||||
|
||||
// Email the mods
|
||||
@@ -159,7 +161,8 @@ api.postChat = {
|
||||
}
|
||||
|
||||
if (!group) throw new NotFound(res.t('groupNotFound'));
|
||||
if (group.privacy !== 'private' && user.flags.chatRevoked) {
|
||||
|
||||
if (group.privacy !== 'private' && userIsMuted(user)) {
|
||||
throw new NotAuthorized(res.t('chatPrivilegesRevoked'));
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ api.getHeroes = {
|
||||
// Note, while the following routes are called getHero / updateHero
|
||||
// they can be used by admins to get/update any user
|
||||
|
||||
const heroAdminFields = 'contributor balance profile.name purchased items auth flags.chatRevoked';
|
||||
const heroAdminFields = 'contributor balance profile.name purchased items auth flags.chatRevoked flags.chatRevokedEndDate';
|
||||
|
||||
/**
|
||||
* @api {get} /api/v3/hall/heroes/:heroId Get any user ("hero") given the UUID
|
||||
@@ -273,7 +273,9 @@ api.updateHero = {
|
||||
if (updateData.auth && updateData.auth.blocked === false) {
|
||||
hero.auth.blocked = false;
|
||||
}
|
||||
|
||||
if (updateData.flags && _.isBoolean(updateData.flags.chatRevoked)) hero.flags.chatRevoked = updateData.flags.chatRevoked;
|
||||
if (updateData.flags && updateData.flags.chatRevokedEndDate) hero.flags.chatRevokedEndDate = updateData.flags.chatRevokedEndDate;
|
||||
|
||||
let savedHero = await hero.save();
|
||||
let heroJSON = savedHero.toJSON();
|
||||
|
||||
Reference in New Issue
Block a user