From 423aee81af35069de7f80e1557a12e8606d68ac1 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 26 Mar 2009 22:01:49 +0000 Subject: [PATCH] Move broadcast filtering into the command handler. Break out the actual doing of the broadcast so that just that can be overridden. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5699 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../crowd/chat/client/BroadcastHandler.as | 16 ++++++++++++++-- .../threerings/crowd/chat/client/ChatDirector.as | 7 +------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/as/com/threerings/crowd/chat/client/BroadcastHandler.as b/src/as/com/threerings/crowd/chat/client/BroadcastHandler.as index f565af5f2..694a081f6 100644 --- a/src/as/com/threerings/crowd/chat/client/BroadcastHandler.as +++ b/src/as/com/threerings/crowd/chat/client/BroadcastHandler.as @@ -21,6 +21,7 @@ package com.threerings.crowd.chat.client { +import com.threerings.util.MessageBundle; import com.threerings.util.Name; import com.threerings.util.ResultListener; import com.threerings.util.StringUtil; @@ -42,13 +43,16 @@ public class BroadcastHandler extends CommandHandler // mogrify and verify length var chatdir :ChatDirector = ctx.getChatDirector(); args = chatdir.mogrifyChat(args); + args = chatdir.filter(args, null, true); + if (args == null) { + return MessageBundle.compose("m.broadcast_failed", "m.filtered"); + } var err :String = chatdir.checkLength(args); if (err != null) { return err; } - // do the broadcast - chatdir.requestBroadcast(args); + doBroadcast(ctx, args); history[0] = cmd + " "; return ChatCodes.SUCCESS; @@ -58,5 +62,13 @@ public class BroadcastHandler extends CommandHandler { return (null == user.checkAccess(ChatCodes.BROADCAST_ACCESS, null)); } + + /** + * Actually do the broadcast. + */ + protected function doBroadcast (ctx :CrowdContext, msg :String) :void + { + ctx.getChatDirector().requestBroadcast(msg); + } } } diff --git a/src/as/com/threerings/crowd/chat/client/ChatDirector.as b/src/as/com/threerings/crowd/chat/client/ChatDirector.as index bcf119b96..a9ffb2f8e 100644 --- a/src/as/com/threerings/crowd/chat/client/ChatDirector.as +++ b/src/as/com/threerings/crowd/chat/client/ChatDirector.as @@ -437,12 +437,7 @@ public class ChatDirector extends BasicDirector */ public function requestBroadcast (message :String) :void { - message = filter(message, null, true); - if (message == null) { - displayFeedback(_bundle, MessageBundle.compose("m.broadcast_failed", "m.filtered")); - return; - } - + // filtering is now done in the broadcast handler, not here. Java code may differ. var failure :Function = function (reason :String) :void { reason = MessageBundle.compose("m.broadcast_failed", reason); displayFeedback(_bundle, reason);