Tell admins about filtered chat content.
Including chat in games that the admin isn't in.
This commit is contained in:
parent
612bd09978
commit
a505598c0d
|
@ -328,6 +328,7 @@ cah.$.LongPollEvent.HURRY_UP = "hu";
|
||||||
cah.$.LongPollEvent.GAME_JUDGE_LEFT = "gjl";
|
cah.$.LongPollEvent.GAME_JUDGE_LEFT = "gjl";
|
||||||
cah.$.LongPollEvent.KICKED = "k";
|
cah.$.LongPollEvent.KICKED = "k";
|
||||||
cah.$.LongPollEvent.KICKED_FROM_GAME_IDLE = "kfgi";
|
cah.$.LongPollEvent.KICKED_FROM_GAME_IDLE = "kfgi";
|
||||||
|
cah.$.LongPollEvent.FILTERED_CHAT = "FC";
|
||||||
cah.$.LongPollEvent.GAME_STATE_CHANGE = "gsc";
|
cah.$.LongPollEvent.GAME_STATE_CHANGE = "gsc";
|
||||||
|
|
||||||
cah.$.LongPollResponse = function() {
|
cah.$.LongPollResponse = function() {
|
||||||
|
|
|
@ -92,12 +92,22 @@ cah.longpoll.EventHandlers[cah.$.LongPollEvent.BANNED] = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
cah.longpoll.EventHandlers[cah.$.LongPollEvent.CHAT] = function(data) {
|
cah.longpoll.EventHandlers[cah.$.LongPollEvent.CHAT] = function(data) {
|
||||||
|
cah.longpoll.showChat_(data, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
cah.longpoll.EventHandlers[cah.$.LongPollEvent.FILTERED_CHAT] = function(data) {
|
||||||
|
cah.longpoll.showChat_(data, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
cah.longpoll.showChat_ = function(data, wasFiltered) {
|
||||||
var clazz = undefined;
|
var clazz = undefined;
|
||||||
var idcode = data[cah.$.LongPollResponse.ID_CODE];
|
var idcode = data[cah.$.LongPollResponse.ID_CODE];
|
||||||
var title = cah.log.getTitleForIdCode(idcode);
|
var title = cah.log.getTitleForIdCode(idcode);
|
||||||
var sigil = data[cah.$.LongPollResponse.SIGIL];
|
var sigil = data[cah.$.LongPollResponse.SIGIL];
|
||||||
var from = data[cah.$.LongPollResponse.FROM];
|
var from = data[cah.$.LongPollResponse.FROM];
|
||||||
|
var who = sigil + from;
|
||||||
var show = !cah.ignoreList[from];
|
var show = !cah.ignoreList[from];
|
||||||
|
var message = data[cah.$.LongPollResponse.MESSAGE];
|
||||||
var game = null;
|
var game = null;
|
||||||
if (sigil == cah.$.Sigil.ADMIN) {
|
if (sigil == cah.$.Sigil.ADMIN) {
|
||||||
clazz = "admin";
|
clazz = "admin";
|
||||||
|
@ -105,20 +115,29 @@ cah.longpoll.EventHandlers[cah.$.LongPollEvent.CHAT] = function(data) {
|
||||||
}
|
}
|
||||||
if (data[cah.$.LongPollResponse.WALL]) {
|
if (data[cah.$.LongPollResponse.WALL]) {
|
||||||
// treat these specially
|
// treat these specially
|
||||||
cah.log.everyWindow("Global message from " + sigil + from + ": "
|
cah.log.everyWindow("Global message from " + who + ": " + message, clazz, false, title);
|
||||||
+ data[cah.$.LongPollResponse.MESSAGE], clazz, false, title);
|
|
||||||
} else {
|
} else {
|
||||||
if (cah.$.LongPollResponse.GAME_ID in data) {
|
if (cah.$.LongPollResponse.GAME_ID in data) {
|
||||||
game = data[cah.$.LongPollResponse.GAME_ID];
|
game = data[cah.$.LongPollResponse.GAME_ID];
|
||||||
}
|
}
|
||||||
|
if (wasFiltered) {
|
||||||
|
clazz = "error";
|
||||||
|
show = true;
|
||||||
|
// there might be a game id that we're not in
|
||||||
|
if (cah.$.LongPollResponse.GAME_ID in data) {
|
||||||
|
message = "(In game " + game + ") " + message;
|
||||||
|
// always show this in global chat since we're probably not in that game.
|
||||||
|
game = null;
|
||||||
|
}
|
||||||
|
message = "(Filtered) " + message;
|
||||||
|
}
|
||||||
|
|
||||||
// don't display our own chat
|
// don't display our own chat
|
||||||
if (from != cah.nickname && show) {
|
if (from != cah.nickname && show) {
|
||||||
var message = data[cah.$.LongPollResponse.MESSAGE];
|
|
||||||
if (data[cah.$.LongPollResponse.EMOTE]) {
|
if (data[cah.$.LongPollResponse.EMOTE]) {
|
||||||
cah.log.status_with_game(game, "* " + sigil + from + " " + message, clazz, false, title);
|
cah.log.status_with_game(game, "* " + who + " " + message, clazz, false, title);
|
||||||
} else {
|
} else {
|
||||||
cah.log.status_with_game(game, "<" + sigil + from + "> " + message, clazz, false, title);
|
cah.log.status_with_game(game, "<" + who + "> " + message, clazz, false, title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,6 +448,7 @@ public class Constants {
|
||||||
CARDCAST_REMOVE_CARDSET(AjaxOperation.CARDCAST_REMOVE_CARDSET),
|
CARDCAST_REMOVE_CARDSET(AjaxOperation.CARDCAST_REMOVE_CARDSET),
|
||||||
@DuplicationAllowed
|
@DuplicationAllowed
|
||||||
CHAT(AjaxOperation.CHAT),
|
CHAT(AjaxOperation.CHAT),
|
||||||
|
FILTERED_CHAT("FC"),
|
||||||
GAME_BLACK_RESHUFFLE("gbr"),
|
GAME_BLACK_RESHUFFLE("gbr"),
|
||||||
GAME_JUDGE_LEFT("gjl"),
|
GAME_JUDGE_LEFT("gjl"),
|
||||||
GAME_JUDGE_SKIPPED("gjs"),
|
GAME_JUDGE_SKIPPED("gjs"),
|
||||||
|
|
|
@ -91,13 +91,16 @@ public class ChatHandler extends Handler {
|
||||||
} else {
|
} else {
|
||||||
final String message = request.getParameter(AjaxRequest.MESSAGE).trim();
|
final String message = request.getParameter(AjaxRequest.MESSAGE).trim();
|
||||||
|
|
||||||
|
LongPollEvent event = LongPollEvent.CHAT;
|
||||||
final ChatFilter.Result filterResult = chatFilter.filterGlobal(user, message);
|
final ChatFilter.Result filterResult = chatFilter.filterGlobal(user, message);
|
||||||
switch (filterResult) {
|
switch (filterResult) {
|
||||||
case CAPSLOCK:
|
case CAPSLOCK:
|
||||||
return error(ErrorCode.CAPSLOCK);
|
return error(ErrorCode.CAPSLOCK);
|
||||||
case DROP_MESSAGE:
|
case DROP_MESSAGE:
|
||||||
// Don't tell the user we dropped it, and don't send it to everyone else...
|
// Don't tell the user we dropped it, and don't send it to everyone else...
|
||||||
return data;
|
// but let any online admins know about it
|
||||||
|
event = LongPollEvent.FILTERED_CHAT;
|
||||||
|
break;
|
||||||
case NO_MESSAGE:
|
case NO_MESSAGE:
|
||||||
return error(ErrorCode.NO_MSG_SPECIFIED);
|
return error(ErrorCode.NO_MSG_SPECIFIED);
|
||||||
case NOT_ENOUGH_SPACES:
|
case NOT_ENOUGH_SPACES:
|
||||||
|
@ -118,7 +121,7 @@ public class ChatHandler extends Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashMap<ReturnableData, Object> broadcastData = new HashMap<ReturnableData, Object>();
|
final HashMap<ReturnableData, Object> broadcastData = new HashMap<ReturnableData, Object>();
|
||||||
broadcastData.put(LongPollResponse.EVENT, LongPollEvent.CHAT.toString());
|
broadcastData.put(LongPollResponse.EVENT, event.toString());
|
||||||
broadcastData.put(LongPollResponse.FROM, user.getNickname());
|
broadcastData.put(LongPollResponse.FROM, user.getNickname());
|
||||||
broadcastData.put(LongPollResponse.MESSAGE, message);
|
broadcastData.put(LongPollResponse.MESSAGE, message);
|
||||||
broadcastData.put(LongPollResponse.ID_CODE, user.getIdCode());
|
broadcastData.put(LongPollResponse.ID_CODE, user.getIdCode());
|
||||||
|
@ -132,7 +135,11 @@ public class ChatHandler extends Handler {
|
||||||
if (emote) {
|
if (emote) {
|
||||||
broadcastData.put(LongPollResponse.EMOTE, true);
|
broadcastData.put(LongPollResponse.EMOTE, true);
|
||||||
}
|
}
|
||||||
users.broadcastToAll(MessageType.CHAT, broadcastData);
|
if (LongPollEvent.CHAT == event) {
|
||||||
|
users.broadcastToAll(MessageType.CHAT, broadcastData);
|
||||||
|
} else {
|
||||||
|
users.broadcastToList(users.getAdmins(), MessageType.CHAT, broadcastData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -39,6 +39,7 @@ import net.socialgamer.cah.Constants.LongPollEvent;
|
||||||
import net.socialgamer.cah.Constants.LongPollResponse;
|
import net.socialgamer.cah.Constants.LongPollResponse;
|
||||||
import net.socialgamer.cah.Constants.ReturnableData;
|
import net.socialgamer.cah.Constants.ReturnableData;
|
||||||
import net.socialgamer.cah.RequestWrapper;
|
import net.socialgamer.cah.RequestWrapper;
|
||||||
|
import net.socialgamer.cah.data.ConnectedUsers;
|
||||||
import net.socialgamer.cah.data.Game;
|
import net.socialgamer.cah.data.Game;
|
||||||
import net.socialgamer.cah.data.GameManager;
|
import net.socialgamer.cah.data.GameManager;
|
||||||
import net.socialgamer.cah.data.QueuedMessage.MessageType;
|
import net.socialgamer.cah.data.QueuedMessage.MessageType;
|
||||||
|
@ -57,11 +58,14 @@ public class GameChatHandler extends GameWithPlayerHandler {
|
||||||
public static final String OP = AjaxOperation.GAME_CHAT.toString();
|
public static final String OP = AjaxOperation.GAME_CHAT.toString();
|
||||||
|
|
||||||
private final ChatFilter chatFilter;
|
private final ChatFilter chatFilter;
|
||||||
|
private final ConnectedUsers users;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GameChatHandler(final GameManager gameManager, final ChatFilter chatFilter) {
|
public GameChatHandler(final GameManager gameManager, final ChatFilter chatFilter,
|
||||||
|
final ConnectedUsers users) {
|
||||||
super(gameManager);
|
super(gameManager);
|
||||||
this.chatFilter = chatFilter;
|
this.chatFilter = chatFilter;
|
||||||
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,6 +75,7 @@ public class GameChatHandler extends GameWithPlayerHandler {
|
||||||
final boolean emote = request.getParameter(AjaxRequest.EMOTE) != null
|
final boolean emote = request.getParameter(AjaxRequest.EMOTE) != null
|
||||||
&& Boolean.valueOf(request.getParameter(AjaxRequest.EMOTE));
|
&& Boolean.valueOf(request.getParameter(AjaxRequest.EMOTE));
|
||||||
|
|
||||||
|
LongPollEvent event = LongPollEvent.CHAT;
|
||||||
if (request.getParameter(AjaxRequest.MESSAGE) == null) {
|
if (request.getParameter(AjaxRequest.MESSAGE) == null) {
|
||||||
return error(ErrorCode.NO_MSG_SPECIFIED);
|
return error(ErrorCode.NO_MSG_SPECIFIED);
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,7 +87,9 @@ public class GameChatHandler extends GameWithPlayerHandler {
|
||||||
return error(ErrorCode.CAPSLOCK);
|
return error(ErrorCode.CAPSLOCK);
|
||||||
case DROP_MESSAGE:
|
case DROP_MESSAGE:
|
||||||
// Don't tell the user we dropped it, and don't send it to everyone else...
|
// Don't tell the user we dropped it, and don't send it to everyone else...
|
||||||
return data;
|
// but let any online admins know about it
|
||||||
|
event = LongPollEvent.FILTERED_CHAT;
|
||||||
|
break;
|
||||||
case NO_MESSAGE:
|
case NO_MESSAGE:
|
||||||
return error(ErrorCode.NO_MSG_SPECIFIED);
|
return error(ErrorCode.NO_MSG_SPECIFIED);
|
||||||
case NOT_ENOUGH_SPACES:
|
case NOT_ENOUGH_SPACES:
|
||||||
|
@ -103,7 +110,7 @@ public class GameChatHandler extends GameWithPlayerHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashMap<ReturnableData, Object> broadcastData = new HashMap<ReturnableData, Object>();
|
final HashMap<ReturnableData, Object> broadcastData = new HashMap<ReturnableData, Object>();
|
||||||
broadcastData.put(LongPollResponse.EVENT, LongPollEvent.CHAT.toString());
|
broadcastData.put(LongPollResponse.EVENT, event.toString());
|
||||||
broadcastData.put(LongPollResponse.FROM, user.getNickname());
|
broadcastData.put(LongPollResponse.FROM, user.getNickname());
|
||||||
broadcastData.put(LongPollResponse.MESSAGE, message);
|
broadcastData.put(LongPollResponse.MESSAGE, message);
|
||||||
broadcastData.put(LongPollResponse.FROM_ADMIN, user.isAdmin());
|
broadcastData.put(LongPollResponse.FROM_ADMIN, user.isAdmin());
|
||||||
|
@ -111,7 +118,11 @@ public class GameChatHandler extends GameWithPlayerHandler {
|
||||||
broadcastData.put(LongPollResponse.SIGIL, user.getSigil().toString());
|
broadcastData.put(LongPollResponse.SIGIL, user.getSigil().toString());
|
||||||
broadcastData.put(LongPollResponse.GAME_ID, game.getId());
|
broadcastData.put(LongPollResponse.GAME_ID, game.getId());
|
||||||
broadcastData.put(LongPollResponse.EMOTE, emote);
|
broadcastData.put(LongPollResponse.EMOTE, emote);
|
||||||
game.broadcastToPlayers(MessageType.CHAT, broadcastData);
|
if (LongPollEvent.CHAT == event) {
|
||||||
|
game.broadcastToPlayers(MessageType.CHAT, broadcastData);
|
||||||
|
} else {
|
||||||
|
users.broadcastToList(users.getAdmins(), MessageType.CHAT, broadcastData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
Loading…
Reference in New Issue