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
This commit is contained in:
Ray Greenwell
2009-03-26 22:01:49 +00:00
parent 88bec3d641
commit 423aee81af
2 changed files with 15 additions and 8 deletions
@@ -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);
}
}
}
@@ -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);