添加禁止搜索用户和禁止昵称搜索用户的配置项
This commit is contained in:
@@ -71,6 +71,12 @@ message.disable_stranger_chat false
|
|||||||
##黑名单处理策略,0 发送失败,返回被拉黑的错误码;1 发送成功但消息被服务器直接丢弃;
|
##黑名单处理策略,0 发送失败,返回被拉黑的错误码;1 发送成功但消息被服务器直接丢弃;
|
||||||
message.blacklist.strategy 0
|
message.blacklist.strategy 0
|
||||||
|
|
||||||
|
##禁止搜索用户
|
||||||
|
friend.disable_search false
|
||||||
|
|
||||||
|
##禁止按照昵称搜索用户。
|
||||||
|
friend.disable_nick_name_search false
|
||||||
|
|
||||||
##好友请求重复发送的间隔,单位是毫秒,默认是7天,0为不限制
|
##好友请求重复发送的间隔,单位是毫秒,默认是7天,0为不限制
|
||||||
friend.repeat_request_duration 604800000
|
friend.repeat_request_duration 604800000
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ public final class BrokerConstants {
|
|||||||
public static final String MESSAGE_Disable_Stranger_Chat = "message.disable_stranger_chat";
|
public static final String MESSAGE_Disable_Stranger_Chat = "message.disable_stranger_chat";
|
||||||
|
|
||||||
public static final String MESSAGE_Blacklist_Strategy = "message.blacklist.strategy";
|
public static final String MESSAGE_Blacklist_Strategy = "message.blacklist.strategy";
|
||||||
|
|
||||||
|
public static final String FRIEND_Disable_Search = "friend.disable_search";
|
||||||
|
public static final String FRIEND_Disable_NickName_Search = "friend.disable_nick_name_search";
|
||||||
public static final String FRIEND_Repeat_Request_Duration = "friend.repeat_request_duration";
|
public static final String FRIEND_Repeat_Request_Duration = "friend.repeat_request_duration";
|
||||||
public static final String FRIEND_Reject_Request_Duration = "friend.reject_request_duration";
|
public static final String FRIEND_Reject_Request_Duration = "friend.reject_request_duration";
|
||||||
public static final String FRIEND_Request_Expiration_Duration = "friend.request_expiration_duration";
|
public static final String FRIEND_Request_Expiration_Duration = "friend.request_expiration_duration";
|
||||||
|
|||||||
@@ -118,6 +118,9 @@ 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 mDisableSearch = false;
|
||||||
|
private boolean mDisableNicknameSearch = false;
|
||||||
|
|
||||||
private long mFriendRequestDuration = 7 * 24 * 60 * 60 * 1000;
|
private long mFriendRequestDuration = 7 * 24 * 60 * 60 * 1000;
|
||||||
private long mFriendRejectDuration = 30 * 24 * 60 * 60 * 1000;
|
private long mFriendRejectDuration = 30 * 24 * 60 * 60 * 1000;
|
||||||
private long mFriendRequestExpiration = 7 * 24 * 60 * 60 * 1000;
|
private long mFriendRequestExpiration = 7 * 24 * 60 * 60 * 1000;
|
||||||
@@ -130,6 +133,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
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));
|
||||||
@@ -139,6 +143,21 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(MESSAGE_Disable_Stranger_Chat, mDisableStrangerChat + "");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mDisableSearch = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.FRIEND_Disable_Search));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(FRIEND_Disable_Search, mDisableSearch + "");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mDisableNicknameSearch = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.FRIEND_Disable_NickName_Search));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(FRIEND_Disable_NickName_Search, mDisableNicknameSearch + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -146,6 +165,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(FRIEND_Repeat_Request_Duration, mFriendRequestDuration + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -153,6 +173,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(FRIEND_Reject_Request_Duration, mFriendRejectDuration + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -160,6 +181,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(FRIEND_Request_Expiration_Duration, mFriendRequestExpiration + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -167,6 +189,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(CHATROOM_Rejoin_When_Active, mChatroomRejoinWhenActive + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -174,9 +197,14 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(CHATROOM_Participant_Idle_Time, mChatroomParticipantIdleTime + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void printMissConfigLog(String config, String defaultValue) {
|
||||||
|
LOG.info("配置文件中缺少配置项目 {}, 缺省值为 {},可以忽略本提醒,或者更新配置项", config, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initStore() {
|
public void initStore() {
|
||||||
updateSensitiveWord();
|
updateSensitiveWord();
|
||||||
@@ -1612,6 +1640,14 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<WFCMessage.User> searchUser(String keyword, int searchType, int page) {
|
public List<WFCMessage.User> searchUser(String keyword, int searchType, int page) {
|
||||||
|
if (mDisableSearch) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDisableNicknameSearch && searchType == ProtoConstants.SearchUserType.SearchUserType_General) {
|
||||||
|
searchType = ProtoConstants.SearchUserType.SearchUserType_Name_Mobile;
|
||||||
|
}
|
||||||
|
|
||||||
return databaseStore.searchUserFromDB(keyword, searchType, page);
|
return databaseStore.searchUserFromDB(keyword, searchType, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user