添加是否禁止服务器端保存searchable_content字段的配置
This commit is contained in:
@@ -71,6 +71,9 @@ message.disable_stranger_chat false
|
|||||||
##所有命中敏感词的消息都会被记录在敏感词消息表中
|
##所有命中敏感词的消息都会被记录在敏感词消息表中
|
||||||
message.blacklist.strategy 0
|
message.blacklist.strategy 0
|
||||||
|
|
||||||
|
##是否禁止服务器端消息搜索,该功能暂未实现。目前的影响是如果打开,则存储消息时不单独保存_searchable_content字段
|
||||||
|
message.disable_remote_search false
|
||||||
|
|
||||||
##禁止搜索用户
|
##禁止搜索用户
|
||||||
friend.disable_search false
|
friend.disable_search false
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ public final class BrokerConstants {
|
|||||||
public static final String CHATROOM_Participant_Idle_Time = "chatroom.participant_idle_time";
|
public static final String CHATROOM_Participant_Idle_Time = "chatroom.participant_idle_time";
|
||||||
public static final String CHATROOM_Rejoin_When_Active = "chatroom.rejoin_when_active";
|
public static final String CHATROOM_Rejoin_When_Active = "chatroom.rejoin_when_active";
|
||||||
|
|
||||||
|
public static final String MESSAGES_DISABLE_REMOTE_SEARCH = "message.disable_remote_search";
|
||||||
|
|
||||||
private BrokerConstants() {
|
private BrokerConstants() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ import static cn.wildfirechat.proto.ProtoConstants.SearchUserType.*;
|
|||||||
public class DatabaseStore {
|
public class DatabaseStore {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(DatabaseStore.class);
|
private static final Logger LOG = LoggerFactory.getLogger(DatabaseStore.class);
|
||||||
private final ThreadPoolExecutorWrapper mScheduler;
|
private final ThreadPoolExecutorWrapper mScheduler;
|
||||||
|
private boolean disableRemoteMessageSearch = false;
|
||||||
|
public void setDisableRemoteMessageSearch(boolean disableRemoteMessageSearch) {
|
||||||
|
this.disableRemoteMessageSearch = disableRemoteMessageSearch;
|
||||||
|
}
|
||||||
|
|
||||||
public DatabaseStore(ThreadPoolExecutorWrapper scheduler) {
|
public DatabaseStore(ThreadPoolExecutorWrapper scheduler) {
|
||||||
this.mScheduler = scheduler;
|
this.mScheduler = scheduler;
|
||||||
@@ -493,13 +497,24 @@ public class DatabaseStore {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
connection = DBUtil.getConnection();
|
connection = DBUtil.getConnection();
|
||||||
String sql = "insert into " + MessageShardingUtil.getMessageTable(message.getMessageId()) +
|
String table = MessageShardingUtil.getMessageTable(message.getMessageId());
|
||||||
" (`_mid`, `_from`, `_type`, `_target`, `_line`, `_data`, `_searchable_key`, `_dt`, `_content_type`, `_to`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
String sql;
|
||||||
" ON DUPLICATE KEY UPDATE " +
|
if (disableRemoteMessageSearch) {
|
||||||
"`_data` = ?," +
|
sql = "insert into " + table +
|
||||||
"`_searchable_key` = ?," +
|
" (`_mid`, `_from`, `_type`, `_target`, `_line`, `_data`, `_dt`, `_content_type`, `_to`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||||
"`_dt` = ?," +
|
" ON DUPLICATE KEY UPDATE " +
|
||||||
"`_content_type` = ?";
|
"`_data` = ?," +
|
||||||
|
"`_dt` = ?," +
|
||||||
|
"`_content_type` = ?";
|
||||||
|
} else {
|
||||||
|
sql = "insert into " + table +
|
||||||
|
" (`_mid`, `_from`, `_type`, `_target`, `_line`, `_data`, `_searchable_key`, `_dt`, `_content_type`, `_to`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||||
|
" ON DUPLICATE KEY UPDATE " +
|
||||||
|
"`_data` = ?," +
|
||||||
|
"`_searchable_key` = ?," +
|
||||||
|
"`_dt` = ?," +
|
||||||
|
"`_content_type` = ?";
|
||||||
|
}
|
||||||
|
|
||||||
String searchableContent = message.getContent().getSearchableContent() == null ? "" : message.getContent().getSearchableContent();
|
String searchableContent = message.getContent().getSearchableContent() == null ? "" : message.getContent().getSearchableContent();
|
||||||
|
|
||||||
@@ -513,7 +528,9 @@ public class DatabaseStore {
|
|||||||
Blob blob = connection.createBlob();
|
Blob blob = connection.createBlob();
|
||||||
blob.setBytes(1, message.getContent().toByteArray());
|
blob.setBytes(1, message.getContent().toByteArray());
|
||||||
statement.setBlob(index++, blob);
|
statement.setBlob(index++, blob);
|
||||||
statement.setString(index++, searchableContent);
|
if (!disableRemoteMessageSearch) {
|
||||||
|
statement.setString(index++, searchableContent);
|
||||||
|
}
|
||||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||||
statement.setInt(index++, message.getContent().getType());
|
statement.setInt(index++, message.getContent().getType());
|
||||||
String to = message.getToUser();
|
String to = message.getToUser();
|
||||||
@@ -525,7 +542,9 @@ public class DatabaseStore {
|
|||||||
statement.setString(index++, to);
|
statement.setString(index++, to);
|
||||||
|
|
||||||
statement.setBlob(index++, blob);
|
statement.setBlob(index++, blob);
|
||||||
statement.setString(index++, searchableContent);
|
if (!disableRemoteMessageSearch) {
|
||||||
|
statement.setString(index++, searchableContent);
|
||||||
|
}
|
||||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||||
statement.setInt(index++, message.getContent().getType());
|
statement.setInt(index++, message.getContent().getType());
|
||||||
|
|
||||||
|
|||||||
@@ -219,6 +219,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
printMissConfigLog(CHATROOM_Participant_Idle_Time, mChatroomParticipantIdleTime + "");
|
printMissConfigLog(CHATROOM_Participant_Idle_Time, mChatroomParticipantIdleTime + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean disableRemoteMessageSearch = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.MESSAGES_DISABLE_REMOTE_SEARCH, "false"));
|
||||||
|
databaseStore.setDisableRemoteMessageSearch(disableRemoteMessageSearch);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printMissConfigLog(String config, String defaultValue) {
|
private void printMissConfigLog(String config, String defaultValue) {
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ message.disable_stranger_chat false
|
|||||||
##所有命中敏感词的消息都会被记录在敏感词消息表中
|
##所有命中敏感词的消息都会被记录在敏感词消息表中
|
||||||
message.blacklist.strategy 0
|
message.blacklist.strategy 0
|
||||||
|
|
||||||
|
##是否禁止服务器端消息搜索,该功能暂未实现。目前的影响是如果打开,则存储消息时不单独保存_searchable_content字段
|
||||||
|
message.disable_remote_search false
|
||||||
|
|
||||||
##禁止搜索用户
|
##禁止搜索用户
|
||||||
friend.disable_search false
|
friend.disable_search false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user