SDK增加群内成员禁言功能
This commit is contained in:
@@ -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";
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* 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<String> 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<String> getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
||||
public void setMembers(List<String> 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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,17 @@ public class GroupAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
}
|
||||
|
||||
|
||||
public static IMResult<Void> muteGroupMemeber(String operator, String groupId, List<String> groupMemberIds, boolean isManager, List<Integer> 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<Void> kickoffGroupMembers(String operator, String groupId, List<String> groupMemberIds, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Group_Member_Kickoff;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user