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:
Keith Holliday
2018-08-12 12:09:12 -05:00
committed by GitHub
parent 2c921609c1
commit 2a7dfff88a
6 changed files with 90 additions and 13 deletions

View File

@@ -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'));
}

View File

@@ -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();