Cleaned up the fine-grained permissions system a bit so that Yohoho can make
use of it in good conscience. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5117 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1358,7 +1358,7 @@ public class ChatDirector extends BasicDirector
|
||||
|
||||
public boolean checkAccess (BodyObject user)
|
||||
{
|
||||
return user.checkAccess(ChatCodes.BROADCAST_ACCESS, null) == null;
|
||||
return user.checkAccess(ChatCodes.BROADCAST_ACCESS) == null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
package com.threerings.crowd.chat.data;
|
||||
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
import com.threerings.presents.data.Permission;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
|
||||
@@ -40,13 +41,11 @@ public interface ChatCodes extends InvocationCodes
|
||||
/** The message identifier for a chat notification message. */
|
||||
public static final String CHAT_NOTIFICATION = "chat";
|
||||
|
||||
/** The access control identifier for normal chat privileges. See {@link
|
||||
* BodyObject#checkAccess}. */
|
||||
public static final String CHAT_ACCESS = "crowd.chat.chat";
|
||||
/** The access control identifier for normal chat privileges. */
|
||||
public static final Permission CHAT_ACCESS = new Permission();
|
||||
|
||||
/** The access control identifier for broadcast chat privileges. See {@link
|
||||
* BodyObject#checkAccess}. */
|
||||
public static final String BROADCAST_ACCESS = "crowd.chat.broadcast";
|
||||
/** The access control identifier for broadcast chat privileges. */
|
||||
public static final Permission BROADCAST_ACCESS = new Permission();
|
||||
|
||||
/** The configuration key for idle time. */
|
||||
public static final String IDLE_TIME_KEY = "narya.chat.idle_time";
|
||||
|
||||
@@ -52,7 +52,7 @@ import com.threerings.crowd.chat.data.UserMessage;
|
||||
* The chat provider handles the server side of the chat-related invocation services.
|
||||
*/
|
||||
public class ChatProvider
|
||||
implements ChatCodes, InvocationProvider
|
||||
implements InvocationProvider
|
||||
{
|
||||
/** Interface to allow an auto response to a tell message. */
|
||||
public static interface TellAutoResponder
|
||||
@@ -128,13 +128,10 @@ public class ChatProvider
|
||||
throws InvocationException
|
||||
{
|
||||
// ensure that the caller has normal chat privileges
|
||||
BodyObject source = (BodyObject)caller;
|
||||
String errmsg = source.checkAccess(CHAT_ACCESS, null);
|
||||
if (errmsg != null) {
|
||||
throw new InvocationException(errmsg);
|
||||
}
|
||||
InvocationException.requireAccess(caller, ChatCodes.CHAT_ACCESS);
|
||||
|
||||
// deliver the tell message to the target
|
||||
BodyObject source = (BodyObject)caller;
|
||||
deliverTell(createTellMessage(source, message), target, listener);
|
||||
|
||||
// inform the auto-responder if needed
|
||||
@@ -151,11 +148,8 @@ public class ChatProvider
|
||||
throws InvocationException
|
||||
{
|
||||
// make sure the requesting user has broadcast privileges
|
||||
InvocationException.requireAccess(caller, ChatCodes.BROADCAST_ACCESS);
|
||||
BodyObject body = (BodyObject)caller;
|
||||
String errmsg = body.checkAccess(BROADCAST_ACCESS, null);
|
||||
if (errmsg != null) {
|
||||
throw new InvocationException(errmsg);
|
||||
}
|
||||
broadcast(body.getVisibleName(), null, message, false, true);
|
||||
}
|
||||
|
||||
@@ -215,12 +209,12 @@ public class ChatProvider
|
||||
if (_chatForwarder != null && _chatForwarder.forwardTell(message, target, listener)) {
|
||||
return;
|
||||
}
|
||||
throw new InvocationException(USER_NOT_ONLINE);
|
||||
throw new InvocationException(ChatCodes.USER_NOT_ONLINE);
|
||||
}
|
||||
|
||||
if (tobj.status == OccupantInfo.DISCONNECTED) {
|
||||
String errmsg = MessageBundle.compose(
|
||||
USER_DISCONNECTED, TimeUtil.getTimeOrderString(
|
||||
ChatCodes.USER_DISCONNECTED, TimeUtil.getTimeOrderString(
|
||||
System.currentTimeMillis() - tobj.statusTime, TimeUtil.SECOND));
|
||||
throw new InvocationException(errmsg);
|
||||
}
|
||||
@@ -275,7 +269,7 @@ public class ChatProvider
|
||||
}
|
||||
|
||||
} else {
|
||||
SpeakUtil.sendSpeak(object, from, bundle, msg, BROADCAST_MODE);
|
||||
SpeakUtil.sendSpeak(object, from, bundle, msg, ChatCodes.BROADCAST_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user