admin 不检查是否有权限,不过滤敏感词
This commit is contained in:
@@ -46,6 +46,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
|||||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.Message message, Qos1PublishHandler.IMCallback callback) {
|
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.Message message, Qos1PublishHandler.IMCallback callback) {
|
||||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
if (!isAdmin) { //admin do not check the right
|
||||||
int userStatus = m_messagesStore.getUserStatus(fromUser);
|
int userStatus = m_messagesStore.getUserStatus(fromUser);
|
||||||
if (userStatus == 1 || userStatus == 2) {
|
if (userStatus == 1 || userStatus == 2) {
|
||||||
return ErrorCode.ERROR_CODE_FORBIDDEN_SEND_MSG;
|
return ErrorCode.ERROR_CODE_FORBIDDEN_SEND_MSG;
|
||||||
@@ -57,20 +58,19 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group && !m_messagesStore.isMemberInGroup(fromUser, message.getConversation().getTarget())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||||
|
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group && m_messagesStore.isForbiddenInGroup(fromUser, message.getConversation().getTarget())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom && !m_messagesStore.checkUserClientInChatroom(fromUser, clientID, message.getConversation().getTarget())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_IN_CHATROOM;
|
||||||
|
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel && !m_messagesStore.checkUserInChannel(fromUser, message.getConversation().getTarget())) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group &&
|
|
||||||
!m_messagesStore.isMemberInGroup(fromUser, message.getConversation().getTarget())) {
|
|
||||||
errorCode = ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
|
||||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group &&
|
|
||||||
m_messagesStore.isForbiddenInGroup(fromUser, message.getConversation().getTarget())) {
|
|
||||||
errorCode = ErrorCode.ERROR_CODE_NOT_RIGHT;
|
|
||||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom &&
|
|
||||||
!m_messagesStore.checkUserClientInChatroom(fromUser, clientID, message.getConversation().getTarget())) {
|
|
||||||
errorCode = ErrorCode.ERROR_CODE_NOT_IN_CHATROOM;
|
|
||||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel &&
|
|
||||||
!m_messagesStore.checkUserInChannel(fromUser, message.getConversation().getTarget())) {
|
|
||||||
errorCode = ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
|
||||||
} else {
|
|
||||||
long messageId = MessageShardingUtil.generateId();
|
long messageId = MessageShardingUtil.generateId();
|
||||||
message = message.toBuilder().setFromUser(fromUser).setMessageId(messageId).setServerTimestamp(timestamp).build();
|
message = message.toBuilder().setFromUser(fromUser).setMessageId(messageId).setServerTimestamp(timestamp).build();
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean ignoreMsg = false;
|
boolean ignoreMsg = false;
|
||||||
if (message.getContent().getType() == Text) {
|
if (!isAdmin && message.getContent().getType() == Text) {
|
||||||
Set<String> matched = m_messagesStore.handleSensitiveWord(message.getContent().getSearchableContent());
|
Set<String> matched = m_messagesStore.handleSensitiveWord(message.getContent().getSearchableContent());
|
||||||
if (matched != null && !matched.isEmpty()) {
|
if (matched != null && !matched.isEmpty()) {
|
||||||
if (mSensitiveType == 0) {
|
if (mSensitiveType == 0) {
|
||||||
@@ -105,7 +105,6 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
|||||||
ackPayload.writeLong(messageId);
|
ackPayload.writeLong(messageId);
|
||||||
ackPayload.writeLong(timestamp);
|
ackPayload.writeLong(timestamp);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
errorCode = ErrorCode.ERROR_CODE_INVALID_MESSAGE;
|
errorCode = ErrorCode.ERROR_CODE_INVALID_MESSAGE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user