更新channel接口,订阅/取消订阅只能逐个操作
This commit is contained in:
@@ -52,7 +52,6 @@ public interface APIPath {
|
|||||||
String Channel_Update_Profile = "/channel/update_profile";
|
String Channel_Update_Profile = "/channel/update_profile";
|
||||||
String Channel_Message_Send = "/channel/message/send";
|
String Channel_Message_Send = "/channel/message/send";
|
||||||
String Channel_Subscribe = "/channel/subscribe";
|
String Channel_Subscribe = "/channel/subscribe";
|
||||||
String Channel_Unsubscribe = "/channel/unsubscribe";
|
|
||||||
String Channel_Subscriber_List = "/channel/subscriber_list";
|
String Channel_Subscriber_List = "/channel/subscriber_list";
|
||||||
|
|
||||||
String Robot_User_Info = "/robot/user_info";
|
String Robot_User_Info = "/robot/user_info";
|
||||||
|
|||||||
@@ -15,15 +15,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InputChannelSubscribe {
|
public class InputChannelSubscribe {
|
||||||
private List<String> targets;
|
private String target;
|
||||||
private int subscribe; //1,订阅;0,取消订阅
|
private int subscribe; //1,订阅;0,取消订阅
|
||||||
|
|
||||||
public List<String> getTargets() {
|
public String getTarget() {
|
||||||
return targets;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargets(List<String> targets) {
|
public void setTarget(String target) {
|
||||||
this.targets = targets;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSubscribe() {
|
public int getSubscribe() {
|
||||||
|
|||||||
@@ -41,18 +41,18 @@ public class ChannelServiceApi {
|
|||||||
return httpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
return httpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMResult<Void> subscribe(List<String> targets) throws Exception {
|
public IMResult<Void> subscribe(String target) throws Exception {
|
||||||
String path = APIPath.Channel_Subscribe;
|
String path = APIPath.Channel_Subscribe;
|
||||||
InputChannelSubscribe input = new InputChannelSubscribe();
|
InputChannelSubscribe input = new InputChannelSubscribe();
|
||||||
input.setTargets(targets);
|
input.setTarget(target);
|
||||||
input.setSubscribe(1);
|
input.setSubscribe(1);
|
||||||
return httpUtils.httpJsonPost(path, input, Void.class);
|
return httpUtils.httpJsonPost(path, input, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMResult<Void> unsubscribe(List<String> targets) throws Exception {
|
public IMResult<Void> unsubscribe(String target) throws Exception {
|
||||||
String path = APIPath.Channel_Unsubscribe;
|
String path = APIPath.Channel_Subscribe;
|
||||||
InputChannelSubscribe input = new InputChannelSubscribe();
|
InputChannelSubscribe input = new InputChannelSubscribe();
|
||||||
input.setTargets(targets);
|
input.setTarget(target);
|
||||||
input.setSubscribe(0);
|
input.setSubscribe(0);
|
||||||
return httpUtils.httpJsonPost(path, input, Void.class);
|
return httpUtils.httpJsonPost(path, input, Void.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -510,7 +510,15 @@ public class Main {
|
|||||||
ChannelServiceApi channelServiceApi = new ChannelServiceApi("http://localhost", inputCreateChannel.getTargetId(), inputCreateChannel.getSecret());
|
ChannelServiceApi channelServiceApi = new ChannelServiceApi("http://localhost", inputCreateChannel.getTargetId(), inputCreateChannel.getSecret());
|
||||||
|
|
||||||
//3. 测试channel api功能
|
//3. 测试channel api功能
|
||||||
resultVoid = channelServiceApi.subscribe(Arrays.asList("user2","user3"));
|
resultVoid = channelServiceApi.subscribe("user2");
|
||||||
|
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
|
System.out.println("block user done");
|
||||||
|
} else {
|
||||||
|
System.out.println("block user failure");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
resultVoid = channelServiceApi.subscribe("user3");
|
||||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("block user done");
|
System.out.println("block user done");
|
||||||
} else {
|
} else {
|
||||||
@@ -526,7 +534,7 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
resultVoid = channelServiceApi.unsubscribe(Arrays.asList("user2"));
|
resultVoid = channelServiceApi.unsubscribe("user2");
|
||||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("block user done");
|
System.out.println("block user done");
|
||||||
} else {
|
} else {
|
||||||
@@ -535,7 +543,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resultStringList = channelServiceApi.getSubscriberList();
|
resultStringList = channelServiceApi.getSubscriberList();
|
||||||
if (resultStringList != null && resultStringList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultStringList.getResult().getList().contains("user2") && !resultStringList.getResult().getList().contains("user3")) {
|
if (resultStringList != null && resultStringList.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && resultStringList.getResult().getList().contains("user3") && !resultStringList.getResult().getList().contains("user2")) {
|
||||||
System.out.println("block user done");
|
System.out.println("block user done");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("block user failure");
|
System.out.println("block user failure");
|
||||||
|
|||||||
Reference in New Issue
Block a user