添加撤回消息限制
This commit is contained in:
@@ -75,6 +75,9 @@ message.blacklist.strategy 0
|
||||
##是否禁止服务器端消息搜索,该功能暂未实现。目前的影响是如果打开,则存储消息时不单独保存_searchable_content字段
|
||||
message.disable_remote_search false
|
||||
|
||||
##允许客户端撤回消息时限,单位是秒。群组管理员或群主撤回群成员消息、server api不受此限制,可以撤回任意时限内的消息
|
||||
message.recall_time_limit 120
|
||||
|
||||
##禁止搜索用户
|
||||
friend.disable_search false
|
||||
|
||||
|
||||
@@ -142,6 +142,8 @@ public final class BrokerConstants {
|
||||
|
||||
public static final String MESSAGES_DISABLE_REMOTE_SEARCH = "message.disable_remote_search";
|
||||
|
||||
public static final String MESSAGES_RECALL_TIME_LIMIT = "message.recall_time_limit";
|
||||
|
||||
private BrokerConstants() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,8 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private long mChatroomParticipantIdleTime = 900000;
|
||||
private boolean mChatroomRejoinWhenActive = true;
|
||||
|
||||
private long mRecallTimeLimit = 300;
|
||||
|
||||
MemoryMessagesStore(Server server, DatabaseStore databaseStore) {
|
||||
m_Server = server;
|
||||
this.databaseStore = databaseStore;
|
||||
@@ -236,6 +238,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
databaseStore.setDisableRemoteMessageSearch(disableRemoteMessageSearch);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
mRecallTimeLimit = Long.parseLong(m_Server.getConfig().getProperty(BrokerConstants.MESSAGES_RECALL_TIME_LIMIT));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
private void printMissConfigLog(String config, String defaultValue) {
|
||||
@@ -1436,6 +1443,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
IMap<Long, MessageBundle> mIMap = hzInstance.getMap(MESSAGES_MAP);
|
||||
|
||||
MessageBundle messageBundle = mIMap.get(messageUid);
|
||||
long now = System.currentTimeMillis();
|
||||
if (messageBundle != null) {
|
||||
WFCMessage.Message message = messageBundle.getMessage();
|
||||
boolean canRecall = false;
|
||||
@@ -1443,7 +1451,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
canRecall = true;
|
||||
}
|
||||
if (!isAdmin && message.getFromUser().equals(operatorId)) {
|
||||
canRecall = true;
|
||||
if (now - message.getServerTimestamp() > mRecallTimeLimit * 1000) {
|
||||
return ErrorCode.ERROR_CODE_RECALL_TIME_EXPIRED;
|
||||
} else {
|
||||
canRecall = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canRecall && message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group) {
|
||||
@@ -1451,7 +1463,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
WFCMessage.GroupInfo groupInfo = groupMap.get(message.getConversation().getTarget());
|
||||
if (groupInfo == null) {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
return ErrorCode.ERROR_CODE_RECALL_TIME_EXPIRED;
|
||||
}
|
||||
if (operatorId.equals(groupInfo.getOwner())) {
|
||||
canRecall = true;
|
||||
@@ -1482,9 +1494,6 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
String searchContent = message.getContent().getSearchableContent() == null ? "" : message.getContent().getSearchableContent();
|
||||
String cont = message.getContent().getContent() == null ? "" : message.getContent().getContent().replace("\"", "\\\"");
|
||||
String extra = message.getContent().getExtra() == null ? "" : message.getContent().getExtra().replace("\"", "\\\"");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("s", message.getFromUser());
|
||||
json.put("ts", message.getServerTimestamp());
|
||||
|
||||
@@ -40,6 +40,8 @@ public enum ErrorCode {
|
||||
|
||||
ERROR_CODE_ALREADY_FRIENDS(23, "already friends"),
|
||||
|
||||
ERROR_CODE_RECALL_TIME_EXPIRED(24, "time expired"),
|
||||
|
||||
ERROR_CODE_GROUP_EXCEED_MAX_MEMBER_COUNT(240, "group exceed max member count"),
|
||||
ERROR_CODE_GROUP_MUTED(241, "group is muted"),
|
||||
ERROR_CODE_SENSITIVE_MATCHED(242, "sensitive matched"),
|
||||
|
||||
@@ -66,6 +66,9 @@ message.blacklist.strategy 0
|
||||
##是否禁止服务器端消息搜索,该功能暂未实现。目前的影响是如果打开,则存储消息时不单独保存_searchable_content字段
|
||||
message.disable_remote_search false
|
||||
|
||||
##允许客户端撤回消息时限,单位是秒。群组管理员或群主撤回群成员消息、server api不受此限制,可以撤回任意时限内的消息
|
||||
message.recall_time_limit 120
|
||||
|
||||
##禁止搜索用户
|
||||
friend.disable_search false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user