diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index ead437b5d..fae5b6aa7 100755 --- a/broker/config/wildfirechat.conf +++ b/broker/config/wildfirechat.conf @@ -169,6 +169,12 @@ chatroom.rejoin_when_active true ## 当一个聊天室不存在时,如果有用户加入就自动创建 chatroom.create_when_not_exist true +## 是否允许群主不受限制地撤回自己发送的消息。false可以${message.recall_time_limit}撤回自己的消息;true可以撤回任意时间自己的消息。默认为true。 +group.allow_owner_recall_self_msg true + +## 是否允许群管理员不受限制地撤回自己发送的消息。false可以${message.recall_time_limit}撤回自己的消息;true可以撤回任意时间自己的消息。默认为false。 +group.allow_manager_recall_self_msg false + ## 是否允许客户端发送操作群的自定义群通知消息 group.allow_client_custom_operation_notification true diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index 89c93f0d9..0162bb02c 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/broker/src/main/java/io/moquette/BrokerConstants.java @@ -173,6 +173,8 @@ public final class BrokerConstants { public static final String CHATROOM_Create_When_Not_Exist = "chatroom.create_when_not_exist"; + public static final String GROUP_Allow_Owner_Recall_Self_Msg = "group.allow_owner_recall_self_msg"; + public static final String GROUP_Allow_Manager_Recall_Self_Msg = "group.allow_manager_recall_self_msg"; public static final String GROUP_Allow_Client_Custom_Operation_Notification = "group.allow_client_custom_operation_notification"; public static final String GROUP_Allow_Robot_Custom_Operation_Notification = "group.allow_robot_custom_operation_notificatio"; diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index 1c521b161..9554c4ef3 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java @@ -180,6 +180,8 @@ protected boolean removeEldestEntry(Map.Entry eldest) { private String mChannelInfoUpdateCallback; private String mChatroomInfoUpdateCallback; private String mChatroomMemberUpdateCallback; + private boolean mGroupAllowOwnerRecallSelfMsg = false; + private boolean mGroupAllowManagerRecallSelfMsg = false; private boolean mGroupAllowClientCustomOperationNotification; private boolean mGroupAllowRobotCustomOperationNotification; private int mGroupVisibleQuitKickoffNotification; @@ -468,6 +470,17 @@ protected boolean removeEldestEntry(Map.Entry eldest) { } + try { + mGroupAllowOwnerRecallSelfMsg = Boolean.parseBoolean(server.getConfig().getProperty(GROUP_Allow_Owner_Recall_Self_Msg, "true")); + } catch (Exception e) { + + } + try { + mGroupAllowManagerRecallSelfMsg = Boolean.parseBoolean(server.getConfig().getProperty(GROUP_Allow_Manager_Recall_Self_Msg, "false")); + } catch (Exception e) { + + } + try { mGroupAllowClientCustomOperationNotification = Boolean.parseBoolean(server.getConfig().getProperty(GROUP_Allow_Client_Custom_Operation_Notification)); } catch (Exception e) { @@ -2232,7 +2245,28 @@ public ErrorCode recallMessage(long messageUid, String operatorId, String client return ErrorCode.ERROR_CODE_RECALL_TIME_EXPIRED; } if (operatorId.equals(groupInfo.getOwner())) { - canRecall = true; + if(operatorId.equals(message.getFromUser())) { + if(mGroupAllowOwnerRecallSelfMsg) { + canRecall = true; + } + } else { + canRecall = true; + } + } else { + if(message.getFromUser().equals(operatorId) && mGroupAllowManagerRecallSelfMsg) { + MultiMap groupMembers = hzInstance.getMultiMap(GROUP_MEMBERS); + Collection members = groupMembers.get(message.getConversation().getTarget()); + if (members == null || members.size() == 0) { + members = loadGroupMemberFromDB(hzInstance, message.getConversation().getTarget()); + } + for (WFCMessage.GroupMember member : members) { + if (member.getMemberId().equals(operatorId)) { + if (member.getType() == GroupMemberType_Manager || member.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Owner) { + canRecall = true; + } + } + } + } } if(!canRecall && !message.getFromUser().equals(operatorId)) { diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index ce68aff67..4453aab48 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -167,6 +167,12 @@ chatroom.rejoin_when_active true ## 当一个聊天室不存在时,如果有用户加入就自动创建 chatroom.create_when_not_exist true +## 是否允许群主不受限制地撤回自己发送的消息。false可以${message.recall_time_limit}撤回自己的消息;true可以撤回任意时间自己的消息。默认为true。 +group.allow_owner_recall_self_msg true + +## 是否允许群管理员不受限制地撤回自己发送的消息。false可以${message.recall_time_limit}撤回自己的消息;true可以撤回任意时间自己的消息。默认为false。 +group.allow_manager_recall_self_msg false + ## 是否允许客户端发送操作群的自定义群通知消息 group.allow_client_custom_operation_notification true