server api添加订阅接口
This commit is contained in:
@@ -39,6 +39,18 @@ public class GeneralAdmin {
|
||||
return AdminHttpUtils.httpJsonPost(path, inputChannelId, OutputGetChannelInfo.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> subscribeChannel(String channelId, String userId) throws Exception {
|
||||
String path = APIPath.Subscribe_Channel;
|
||||
InputSubscribeChannel input = new InputSubscribeChannel(channelId, userId, 1);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> unsubscribeChannel(String channelId, String userId) throws Exception {
|
||||
String path = APIPath.Subscribe_Channel;
|
||||
InputSubscribeChannel input = new InputSubscribeChannel(channelId, userId, 0);
|
||||
return AdminHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
|
||||
//以下仅专业版支持
|
||||
public static IMResult<Void> setConversationTop(String userId, int conversationType, String target, int line, boolean isTop) throws Exception {
|
||||
String key = conversationType + "-" + line + "-" + target;
|
||||
|
||||
@@ -1183,8 +1183,8 @@ public class Main {
|
||||
}
|
||||
|
||||
PojoGroupMember m = new PojoGroupMember();
|
||||
m.setMember_id("user1");
|
||||
m.setAlias("hello user1");
|
||||
m.setMember_id("user0");
|
||||
m.setAlias("hello user0");
|
||||
|
||||
voidIMResult = robotService.addGroupMembers(groupInfo.getTarget_id(), Arrays.asList(m), null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
@@ -1390,8 +1390,16 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultVoid = GeneralAdmin.subscribeChannel(channelId, "userId4");
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("subscribe done");
|
||||
} else {
|
||||
System.out.println("subscribe failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputStringList> resultStringList = channelServiceApi.getSubscriberList();
|
||||
if (resultStringList != null && resultStringList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultStringList.getResult().getList().contains("userId2") && resultStringList.getResult().getList().contains("userId3")) {
|
||||
if (resultStringList != null && resultStringList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultStringList.getResult().getList().contains("userId2") && resultStringList.getResult().getList().contains("userId3") && resultStringList.getResult().getList().contains("userId4")) {
|
||||
System.out.println("get subscriber done");
|
||||
} else {
|
||||
System.out.println("get subscriber failure");
|
||||
|
||||
Reference in New Issue
Block a user