diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index 4462df65..a5126153 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -53,6 +53,7 @@ public interface APIPath { String Group_Member_Kickoff = "/admin/group/member/del"; String Group_Member_Quit = "/admin/group/member/quit"; String Group_Set_Manager = "/admin/group/manager/set"; + String Group_Mute_Member = "/admin/group/manager/mute"; String Get_User_Groups = "/admin/group/of_user"; diff --git a/common/src/main/java/cn/wildfirechat/pojos/GroupNotificationBinaryContent.java b/common/src/main/java/cn/wildfirechat/pojos/GroupNotificationBinaryContent.java index 8ad45e8b..49c1caf4 100644 --- a/common/src/main/java/cn/wildfirechat/pojos/GroupNotificationBinaryContent.java +++ b/common/src/main/java/cn/wildfirechat/pojos/GroupNotificationBinaryContent.java @@ -145,6 +145,8 @@ public class GroupNotificationBinaryContent { return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_SET_MANAGER); } - + public WFCMessage.MessageContent getMuteGroupMemberNotifyContent() { + return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MUTE_MEMBER); + } } diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputMuteGroupMember.java b/common/src/main/java/cn/wildfirechat/pojos/InputMuteGroupMember.java new file mode 100755 index 00000000..b767d579 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/InputMuteGroupMember.java @@ -0,0 +1,72 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package cn.wildfirechat.pojos; + + +import cn.wildfirechat.proto.WFCMessage; +import io.netty.util.internal.StringUtil; + +import java.util.List; + +public class InputMuteGroupMember extends InputGroupBase { + private String group_id; + private List members; + private boolean is_manager; + + public String getGroup_id() { + return group_id; + } + + public void setGroup_id(String group_id) { + this.group_id = group_id; + } + + public List getMembers() { + return members; + } + + public void setMembers(List members) { + this.members = members; + } + + public boolean isIs_manager() { + return is_manager; + } + + public void setIs_manager(boolean is_manager) { + this.is_manager = is_manager; + } + + public boolean isValide() { + if (StringUtil.isNullOrEmpty(operator) || StringUtil.isNullOrEmpty(group_id) || members == null || members.isEmpty()) { + return false; + } + return true; + } + + public WFCMessage.SetGroupManagerRequest toProtoGroupRequest() { + WFCMessage.SetGroupManagerRequest.Builder addGroupBuilder = WFCMessage.SetGroupManagerRequest.newBuilder(); + addGroupBuilder.setGroupId(group_id); + addGroupBuilder.addAllUserId(members); + addGroupBuilder.setType(is_manager ? 1 : 0); + + if (to_lines != null) { + for (Integer line : to_lines + ) { + addGroupBuilder.addToLine(line); + } + } + + if (notify_message != null) { + addGroupBuilder.setNotifyContent(notify_message.toProtoMessageContent()); + } + return addGroupBuilder.build(); + } + +} diff --git a/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java b/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java index 8f169e02..d432dad2 100644 --- a/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java +++ b/common/src/main/java/cn/wildfirechat/proto/ProtoConstants.java @@ -181,5 +181,6 @@ public class ProtoConstants { public static final int MESSAGE_CONTENT_TYPE_CHANGE_SEARCHABLE = 116; public static final int MESSAGE_CONTENT_TYPE_SET_MANAGER = 117; + public static final int MESSAGE_CONTENT_TYPE_MUTE_MEMBER = 118; } diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java b/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java index 5c23beab..fae8a5b2 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java @@ -101,7 +101,17 @@ public class GroupAdmin { return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class); } - + public static IMResult muteGroupMemeber(String operator, String groupId, List groupMemberIds, boolean isManager, List to_lines, MessagePayload notify_message) throws Exception { + String path = APIPath.Group_Mute_Member; + InputMuteGroupMember addGroupMember = new InputMuteGroupMember(); + addGroupMember.setGroup_id(groupId); + addGroupMember.setMembers(groupMemberIds); + addGroupMember.setIs_manager(isManager); + addGroupMember.setOperator(operator); + addGroupMember.setTo_lines(to_lines); + addGroupMember.setNotify_message(notify_message); + return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class); + } public static IMResult kickoffGroupMembers(String operator, String groupId, List groupMemberIds, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Group_Member_Kickoff; diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java index 536176c1..3fa86995 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java @@ -37,6 +37,7 @@ public class Main { testChatroom(); testMessage(); testGeneralApi(); + testDevice(); System.out.println("Congratulation, all admin test case passed!!!!!!!"); } @@ -413,6 +414,23 @@ public class Main { System.exit(-1); } + voidIMResult = GroupAdmin.muteGroupMemeber("user1", groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), true, null, null); + if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("mute group member success"); + } else { + System.out.println("mute group member failure"); + System.exit(-1); + } + + voidIMResult = GroupAdmin.muteGroupMemeber("user1", groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), false, null, null); + if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("unmute group member success"); + } else { + System.out.println("unmute group member failure"); + System.exit(-1); + } + + voidIMResult = GroupAdmin.quitGroup("user4", groupInfo.getTarget_id(), null, null); if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {