添加频道获取自己信息的接口
This commit is contained in:
@@ -50,6 +50,7 @@ public interface APIPath {
|
||||
|
||||
String Channel_User_Info = "/channel/user_info";
|
||||
String Channel_Update_Profile = "/channel/update_profile";
|
||||
String Channel_Get_Profile = "/channel/get_profile";
|
||||
String Channel_Message_Send = "/channel/message/send";
|
||||
String Channel_Subscribe = "/channel/subscribe";
|
||||
String Channel_Subscriber_List = "/channel/subscriber_list";
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class OutputGetChannelInfo {
|
||||
private String channelId;
|
||||
private String name;
|
||||
private String desc;
|
||||
private String portrait;
|
||||
private String extra;
|
||||
private String owner;
|
||||
private int status;
|
||||
private long updateDt;
|
||||
private String callback;
|
||||
private int automatic;
|
||||
|
||||
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
}
|
||||
|
||||
public void setChannelId(String channelId) {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getPortrait() {
|
||||
return portrait;
|
||||
}
|
||||
|
||||
public void setPortrait(String portrait) {
|
||||
this.portrait = portrait;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public long getUpdateDt() {
|
||||
return updateDt;
|
||||
}
|
||||
|
||||
public void setUpdateDt(long updateDt) {
|
||||
this.updateDt = updateDt;
|
||||
}
|
||||
|
||||
public String getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public void setCallback(String callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public int getAutomatic() {
|
||||
return automatic;
|
||||
}
|
||||
|
||||
public void setAutomatic(int automatic) {
|
||||
this.automatic = automatic;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,11 @@ public class ChannelServiceApi {
|
||||
return httpUtils.httpJsonPost(path, modifyChannelInfo, Void.class);
|
||||
}
|
||||
|
||||
public IMResult<OutputGetChannelInfo> getChannelInfo() throws Exception {
|
||||
String path = APIPath.Channel_Get_Profile;
|
||||
return httpUtils.httpJsonPost(path, null, OutputGetChannelInfo.class);
|
||||
}
|
||||
|
||||
public IMResult<SendMessageResult> sendMessage(int line, List<String> targets, MessagePayload payload) throws Exception {
|
||||
String path = APIPath.Channel_Message_Send;
|
||||
SendChannelMessageData messageData = new SendChannelMessageData();
|
||||
|
||||
@@ -494,13 +494,13 @@ public class Main {
|
||||
}
|
||||
|
||||
//测试频道API功能,仅专业版支持
|
||||
//1. 先创建频道
|
||||
//1. 先使用admin api创建频道
|
||||
inputCreateChannel = new InputCreateChannel();
|
||||
inputCreateChannel.setName("testChannel");
|
||||
inputCreateChannel.setOwner("user1");
|
||||
resultCreateChannel = GeneralAdmin.createChannel(inputCreateChannel);
|
||||
if (resultCreateChannel != null && resultCreateChannel.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("success");
|
||||
System.out.println("create channel success");
|
||||
} else {
|
||||
System.out.println("create channel failure");
|
||||
System.exit(-1);
|
||||
@@ -512,41 +512,41 @@ public class Main {
|
||||
//3. 测试channel api功能
|
||||
resultVoid = channelServiceApi.subscribe("user2");
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("block user done");
|
||||
System.out.println("subscribe success");
|
||||
} else {
|
||||
System.out.println("block user failure");
|
||||
System.out.println("subscribe failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultVoid = channelServiceApi.subscribe("user3");
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("block user done");
|
||||
System.out.println("subscribe done");
|
||||
} else {
|
||||
System.out.println("block user failure");
|
||||
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("user2") && resultStringList.getResult().getList().contains("user3")) {
|
||||
System.out.println("block user done");
|
||||
System.out.println("get subscriber done");
|
||||
} else {
|
||||
System.out.println("block user failure");
|
||||
System.out.println("get subscriber failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultVoid = channelServiceApi.unsubscribe("user2");
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("block user done");
|
||||
System.out.println("unsubscriber done");
|
||||
} else {
|
||||
System.out.println("block user failure");
|
||||
System.out.println("unsubscriber failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultStringList = channelServiceApi.getSubscriberList();
|
||||
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("get subscriber done");
|
||||
} else {
|
||||
System.out.println("block user failure");
|
||||
System.out.println("get subscriber failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ public class Main {
|
||||
if (resultGetUserInfo1 != null && resultGetUserInfo1.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get user info success");
|
||||
} else {
|
||||
System.out.println("get user info by name failure");
|
||||
System.out.println("get user info failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
@@ -565,9 +565,9 @@ public class Main {
|
||||
|
||||
resultSendMessage = channelServiceApi.sendMessage(0, null,payload);
|
||||
if (resultSendMessage != null && resultSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("send message success");
|
||||
System.out.println("send message to all the subscriber success");
|
||||
} else {
|
||||
System.out.println("send message failure");
|
||||
System.out.println("send message to all the subscriber failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
@@ -575,14 +575,22 @@ public class Main {
|
||||
|
||||
resultSendMessage = channelServiceApi.sendMessage(0, Arrays.asList("user2"),payload);
|
||||
if (resultSendMessage != null && resultSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("send message success");
|
||||
System.out.println("send message to user2 success");
|
||||
} else {
|
||||
System.out.println("send message failure");
|
||||
System.out.println("send message to user2 failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult = channelServiceApi.modifyChannelInfo(ProtoConstants.ModifyChannelInfoType.Modify_Channel_Desc, "this is a test channel, update at:" + new Date().toString());
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("modify channel profile success");
|
||||
} else {
|
||||
System.out.println("modify channel profile failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<OutputGetChannelInfo> outputGetChannelInfoIMResult = channelServiceApi.getChannelInfo();
|
||||
if (outputGetChannelInfoIMResult != null && outputGetChannelInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("destroy user success");
|
||||
} else {
|
||||
System.out.println("destroy user failure");
|
||||
|
||||
Reference in New Issue
Block a user