添加是否允许陌生人聊天的配置
This commit is contained in:
@@ -61,6 +61,9 @@ message.remote_history_message 0
|
|||||||
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
||||||
message.max_queue 1024
|
message.max_queue 1024
|
||||||
|
|
||||||
|
##是否允许陌生人聊天
|
||||||
|
message.disable_stranger_chat false
|
||||||
|
|
||||||
#*********************************************************************
|
#*********************************************************************
|
||||||
# hazelcase configuration
|
# hazelcase configuration
|
||||||
#*********************************************************************
|
#*********************************************************************
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ public final class BrokerConstants {
|
|||||||
|
|
||||||
public static final String MESSAGE_Max_Queue = "message.max_queue";
|
public static final String MESSAGE_Max_Queue = "message.max_queue";
|
||||||
|
|
||||||
|
public static final String MESSAGE_Disable_Stranger_Chat = "message.disable_stranger_chat";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private BrokerConstants() {
|
private BrokerConstants() {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -56,12 +57,12 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private) {
|
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private) {
|
||||||
if (m_messagesStore.isBlacked(message.getConversation().getTarget(), fromUser)) {
|
errorCode = m_messagesStore.isAllowUserMessage(message.getConversation().getTarget(), fromUser);
|
||||||
return ErrorCode.ERROR_CODE_IN_BLACK_LIST;
|
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
return errorCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group ) {
|
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group ) {
|
||||||
errorCode = m_messagesStore.canSendMessageInGroup(fromUser, message.getConversation().getTarget());
|
errorCode = m_messagesStore.canSendMessageInGroup(fromUser, message.getConversation().getTarget());
|
||||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.hazelcast.util.StringUtil;
|
|||||||
import com.xiaoleilu.loServer.model.FriendData;
|
import com.xiaoleilu.loServer.model.FriendData;
|
||||||
import cn.wildfirechat.pojos.InputOutputUserBlockStatus;
|
import cn.wildfirechat.pojos.InputOutputUserBlockStatus;
|
||||||
import cn.wildfirechat.common.ErrorCode;
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
|
import io.moquette.BrokerConstants;
|
||||||
import io.moquette.server.Constants;
|
import io.moquette.server.Constants;
|
||||||
import io.moquette.server.Server;
|
import io.moquette.server.Server;
|
||||||
import io.moquette.spi.IMatchingCondition;
|
import io.moquette.spi.IMatchingCondition;
|
||||||
@@ -118,12 +119,20 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
private ConcurrentHashMap<String, Boolean> userPushHiddenDetail = new ConcurrentHashMap<>();
|
private ConcurrentHashMap<String, Boolean> userPushHiddenDetail = new ConcurrentHashMap<>();
|
||||||
private ConcurrentHashMap<String, Boolean> userConvSlientMap = new ConcurrentHashMap<>();
|
private ConcurrentHashMap<String, Boolean> userConvSlientMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private boolean mDisableStrangerChat = false;
|
||||||
|
|
||||||
MemoryMessagesStore(Server server, DatabaseStore databaseStore) {
|
MemoryMessagesStore(Server server, DatabaseStore databaseStore) {
|
||||||
m_Server = server;
|
m_Server = server;
|
||||||
this.databaseStore = databaseStore;
|
this.databaseStore = databaseStore;
|
||||||
IS_MESSAGE_ROAMING = "1".equals(m_Server.getConfig().getProperty(MESSAGE_ROAMING));
|
IS_MESSAGE_ROAMING = "1".equals(m_Server.getConfig().getProperty(MESSAGE_ROAMING));
|
||||||
IS_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_History_Message));
|
IS_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_History_Message));
|
||||||
Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue));
|
Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue));
|
||||||
|
|
||||||
|
try {
|
||||||
|
mDisableStrangerChat = Boolean.parseBoolean(Server.getConfig().getProperty(BrokerConstants.MESSAGE_Disable_Stranger_Chat));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1624,7 +1633,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBlacked(String fromUser, String userId) {
|
public ErrorCode isAllowUserMessage(String fromUser, String userId) {
|
||||||
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
HazelcastInstance hzInstance = m_Server.getHazelcastInstance();
|
||||||
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
MultiMap<String, FriendData> friendsMap = hzInstance.getMultiMap(USER_FRIENDS);
|
||||||
|
|
||||||
@@ -1637,14 +1646,18 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
for (FriendData friendData : friendDatas) {
|
for (FriendData friendData : friendDatas) {
|
||||||
if (friendData.getFriendUid().equals(userId)) {
|
if (friendData.getFriendUid().equals(userId)) {
|
||||||
if (friendData.getBlacked() == 1) {
|
if (friendData.getBlacked() == 1) {
|
||||||
return true;
|
return ErrorCode.ERROR_CODE_IN_BLACK_LIST;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (mDisableStrangerChat) {
|
||||||
|
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrorCode.ERROR_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ public interface IMessagesStore {
|
|||||||
ErrorCode deleteFriend(String userId, String friendUid, long[] head);
|
ErrorCode deleteFriend(String userId, String friendUid, long[] head);
|
||||||
ErrorCode blackUserRequest(String fromUser, String targetUserId, int status, long[] head);
|
ErrorCode blackUserRequest(String fromUser, String targetUserId, int status, long[] head);
|
||||||
ErrorCode SyncFriendRequestUnread(String userId, long unreadDt, long[] head);
|
ErrorCode SyncFriendRequestUnread(String userId, long unreadDt, long[] head);
|
||||||
boolean isBlacked(String fromUser, String userId);
|
ErrorCode isAllowUserMessage(String fromUser, String userId);
|
||||||
ErrorCode setFriendAliasRequest(String fromUser, String targetUserId, String alias, long[] head);
|
ErrorCode setFriendAliasRequest(String fromUser, String targetUserId, String alias, long[] head);
|
||||||
|
|
||||||
ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId);
|
ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId);
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ message.remote_history_message 0
|
|||||||
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
||||||
message.max_queue 1024
|
message.max_queue 1024
|
||||||
|
|
||||||
|
##是否允许陌生人聊天
|
||||||
|
message.disable_stranger_chat false
|
||||||
|
|
||||||
#*********************************************************************
|
#*********************************************************************
|
||||||
# hazelcase configuration
|
# hazelcase configuration
|
||||||
#*********************************************************************
|
#*********************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user