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:
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
package com.threerings.crowd.chat.client {
|
package com.threerings.crowd.chat.client {
|
||||||
|
|
||||||
|
import com.threerings.util.MessageBundle;
|
||||||
import com.threerings.util.Name;
|
import com.threerings.util.Name;
|
||||||
import com.threerings.util.ResultListener;
|
import com.threerings.util.ResultListener;
|
||||||
import com.threerings.util.StringUtil;
|
import com.threerings.util.StringUtil;
|
||||||
@@ -42,13 +43,16 @@ public class BroadcastHandler extends CommandHandler
|
|||||||
// mogrify and verify length
|
// mogrify and verify length
|
||||||
var chatdir :ChatDirector = ctx.getChatDirector();
|
var chatdir :ChatDirector = ctx.getChatDirector();
|
||||||
args = chatdir.mogrifyChat(args);
|
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);
|
var err :String = chatdir.checkLength(args);
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the broadcast
|
doBroadcast(ctx, args);
|
||||||
chatdir.requestBroadcast(args);
|
|
||||||
|
|
||||||
history[0] = cmd + " ";
|
history[0] = cmd + " ";
|
||||||
return ChatCodes.SUCCESS;
|
return ChatCodes.SUCCESS;
|
||||||
@@ -58,5 +62,13 @@ public class BroadcastHandler extends CommandHandler
|
|||||||
{
|
{
|
||||||
return (null == user.checkAccess(ChatCodes.BROADCAST_ACCESS, null));
|
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
|
public function requestBroadcast (message :String) :void
|
||||||
{
|
{
|
||||||
message = filter(message, null, true);
|
// filtering is now done in the broadcast handler, not here. Java code may differ.
|
||||||
if (message == null) {
|
|
||||||
displayFeedback(_bundle, MessageBundle.compose("m.broadcast_failed", "m.filtered"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var failure :Function = function (reason :String) :void {
|
var failure :Function = function (reason :String) :void {
|
||||||
reason = MessageBundle.compose("m.broadcast_failed", reason);
|
reason = MessageBundle.compose("m.broadcast_failed", reason);
|
||||||
displayFeedback(_bundle, reason);
|
displayFeedback(_bundle, reason);
|
||||||
|
|||||||
Reference in New Issue
Block a user