Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b98461946 | ||
|
|
b10ee75da5 | ||
|
|
a9792b10ac | ||
|
|
51bfb788ac | ||
|
|
82088db682 | ||
|
|
463e3e766a | ||
|
|
4b00b873c3 | ||
|
|
0c06e28116 | ||
|
|
7ea6ea08fd | ||
|
|
b61d292fb5 | ||
|
|
0aba453a24 |
@@ -1,22 +1,27 @@
|
||||
## 野火IM解决方案
|
||||
|
||||
野火IM是一套跨平台、核心功能开源的即时通讯解决方案,主要包含以下内容。
|
||||
野火IM是专业级即时通讯和实时音视频整体解决方案,由北京野火无限网络科技有限公司维护和支持。
|
||||
|
||||
主要特性有:私有部署安全可靠,性能强大,功能齐全,全平台支持,开源率高,部署运维简单,二次开发友好,方便与第三方系统对接或者嵌入现有系统中。详细情况请参考[在线文档](https://docs.wildfirechat.cn)。
|
||||
|
||||
主要包括一下项目:
|
||||
|
||||
| [GitHub仓库地址(主站)](https://github.com/wildfirechat) | [码云仓库地址(镜像)](https://gitee.com/wfchat) | 说明 | 备注 |
|
||||
| ------------------------------------------------------------ | ----------------------------------------------------- | ----------------------------------------------------------------------------------------- | ---------------------------------------------- |
|
||||
| [android-chat](https://github.com/wildfirechat/android-chat) | [android-chat](https://gitee.com/wfchat/android-chat) | 野火IM Android SDK源码和App源码 | 可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [ios-chat](https://github.com/wildfirechat/ios-chat) | [ios-chat](https://gitee.com/wfchat/ios-chat) | 野火IM iOS SDK源码和App源码 | 可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [pc-chat](https://github.com/wildfirechat/pc-chat) | [pc-chat](https://gitee.com/wfchat/pc-chat) | 基于[Electron](https://electronjs.org/)开发的PC平台应用 | |
|
||||
| [web-chat](https://github.com/wildfirechat/web-chat) | [web-chat](https://gitee.com/wfchat/web-chat) | Web平台的Demo, [体验地址](http://web.wildfirechat.cn) | |
|
||||
| [wx-chat](https://github.com/wildfirechat/wx-chat) | [wx-chat](https://gitee.com/wfchat/wx-chat) | 微信小程序平台的Demo | |
|
||||
| [server](https://github.com/wildfirechat/server) | [server](https://gitee.com/wfchat/server) | IM server | |
|
||||
| [app server](https://github.com/wildfirechat/app_server) | [app server](https://gitee.com/wfchat/app_server) | 应用服务端 | |
|
||||
| [robot_server](https://github.com/wildfirechat/robot_server) | [robot_server](https://gitee.com/wfchat/robot_server) | 机器人服务端 | |
|
||||
| [push_server](https://github.com/wildfirechat/push_server) | [push_server](https://gitee.com/wfchat/push_server) | 推送服务器 | |
|
||||
| [docs](https://github.com/wildfirechat/docs) | [docs](https://gitee.com/wfchat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明,[在线查看](https://docs.wildfirechat.cn/) | | |
|
||||
|
||||
| 仓库 | 说明 | 备注 |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------- | ---- |
|
||||
| [android-chat](https://github.com/wildfirechat/android-chat) | 野火IM Android SDK源码和App源码 |可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [ios-chat](https://github.com/wildfirechat/ios-chat) | 野火IM iOS SDK源码和App源码 |可以很方便地进行二次开发,或集成到现有应用当中 |
|
||||
| [pc-chat](https://github.com/wildfirechat/pc-chat) | 基于[Electron](https://electronjs.org/)开发的PC平台应用 | |
|
||||
| [web-chat](https://github.com/wildfirechat/web-chat) | Web平台的Demo, [体验地址](http://web.wildfirechat.net) | |
|
||||
| [wx-chat](https://github.com/wildfirechat/wx-chat) | 微信小程序平台的Demo | |
|
||||
| [server](https://github.com/wildfirechat/server) | IM server | |
|
||||
| [app server](https://github.com/wildfirechat/app_server) | 应用服务端 | |
|
||||
| [robot_server](https://github.com/wildfirechat/robot_server) | 机器人服务端 | |
|
||||
| [push_server](https://github.com/wildfirechat/push_server) | 推送服务器 | |
|
||||
| [docs](https://github.com/wildfirechat/docs) | 野火IM相关文档,包含设计、概念、开发、使用说明 | | | |
|
||||
|
||||
# server
|
||||
本工程为野火IM 社区版IM服务软件。野火IM作为一个通用的即时通讯解决方案,可以集成到各种应用中。请阅读[docs](http://docs.wildfirechat.net)或下载服务器[发布版本](https://github.com/wildfirechat/server/releases)
|
||||
本工程为野火IM 社区版IM服务软件。野火IM作为一个通用的即时通讯解决方案,既可以直接使用,也可以集成到各种应用中。
|
||||
|
||||
|
||||
开发一套IM系统真的很艰辛,请路过的朋友们给点个star,支持我们坚持下去🙏🙏🙏🙏🙏
|
||||
|
||||
@@ -135,6 +135,10 @@ group.visible_quit_or_kickoff_notification 0
|
||||
## 注意,修改本配置不会对已经同步的信息产生影响。
|
||||
#user.hide_properties 3,4,5
|
||||
|
||||
# 好友/好友请求/用户设置 这三类数据同步的最大条目数。之前是客户第一次登录时,会把所有的对应数据一次下载到客户端,但如果有特别多的信息,会导致无法同步到客户端,
|
||||
# 因此需要分段多次同步,此开关定义了每次同步的数据的条数。此需要客户端支持,客户端SDK在2021.5.25日后支持此功能。如果确认所有客户端都在这个日志之后才可以打开此设置。
|
||||
#sync.data_part_size 1000
|
||||
|
||||
#*********************************************************************
|
||||
# hazelcase configuration
|
||||
#*********************************************************************
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.64</version>
|
||||
<version>0.66</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
@@ -84,7 +84,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.4.1</version>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class AddFriendRequestAction extends AdminAction {
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
return new Result(errorCode);
|
||||
}, !input.isForce());
|
||||
}, input.isForce());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -157,6 +157,7 @@ public final class BrokerConstants {
|
||||
public static final String GROUP_Visible_Quit_Kickoff_Notification = "group.visible_quit_or_kickoff_notification";
|
||||
|
||||
public static final String USER_HIDE_PROPERTIES = "user.hide_properties";
|
||||
public static final String SYNC_Data_Part_Size = "sync.data_part_size";
|
||||
|
||||
public static final String MESSAGES_FORBIDDEN_CLIENT_SEND_TYPES = "message.forbidden_client_send_types";
|
||||
public static final String MESSAGES_BLACKLIST_EXCEPTION_TYPES = "message.blacklist_exception_types";
|
||||
|
||||
@@ -154,6 +154,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private String mChatroomMemberUpdateCallback;
|
||||
private boolean mGroupAllowClientCustomOperationNotification;
|
||||
private int mGroupVisibleQuitKickoffNotification;
|
||||
private int mSyncDataPartSize = 0;
|
||||
|
||||
private Set<Integer> mUserHideProperties = new HashSet<>();
|
||||
|
||||
@@ -381,6 +382,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
mSyncDataPartSize = Integer.parseInt(server.getConfig().getProperty(SYNC_Data_Part_Size, "0"));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
String userHideStr = server.getConfig().getProperty(USER_HIDE_PROPERTIES);
|
||||
@@ -2573,6 +2580,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
if(mSyncDataPartSize > 0 && out.size() > mSyncDataPartSize) {
|
||||
out.sort(Comparator.comparingLong(FriendData::getTimestamp));
|
||||
out = out.subList(0, mSyncDataPartSize);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -2618,12 +2630,16 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
if(mSyncDataPartSize > 0 && out.size() > mSyncDataPartSize) {
|
||||
out.sort(Comparator.comparingLong(WFCMessage.FriendRequest::getUpdateDt));
|
||||
out = out.subList(0, mSyncDataPartSize);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorCode saveAddFriendRequest(String userId, WFCMessage.AddFriendRequest request, long[] head, boolean isAdmin) {
|
||||
if (mDisableFriendRequest) {
|
||||
if (!isAdmin && mDisableFriendRequest) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
@@ -3111,6 +3127,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
if(mSyncDataPartSize > 0 && ec == ErrorCode.ERROR_CODE_SUCCESS && builder.getEntryCount() > mSyncDataPartSize) {
|
||||
List<WFCMessage.UserSettingEntry> list = new ArrayList<>(builder.getEntryList());
|
||||
list.sort(Comparator.comparingLong(WFCMessage.UserSettingEntry::getUpdateDt));
|
||||
list = list.subList(0, mSyncDataPartSize);
|
||||
builder.clearEntry().addAllEntry(list);
|
||||
}
|
||||
return ec;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.64</version>
|
||||
<version>0.66</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -70,6 +70,11 @@ public interface APIPath {
|
||||
String Get_System_Setting = "/admin/system/get_setting";
|
||||
String Put_System_Setting = "/admin/system/put_setting";
|
||||
|
||||
String Conference_List = "/admin/conference/list";
|
||||
String Conference_List_Participant = "/admin/conference/list_participant";
|
||||
String Conference_Create = "/admin/conference/create";
|
||||
String Conference_Destroy = "/admin/conference/destroy";
|
||||
|
||||
String Channel_User_Info = "/channel/user_info";
|
||||
String Channel_Update_Profile = "/channel/update_profile";
|
||||
String Channel_Get_Profile = "/channel/get_profile";
|
||||
|
||||
@@ -38,6 +38,7 @@ public enum ErrorCode {
|
||||
|
||||
ERROR_CODE_NOT_IN_CHANNEL(21, "not in channel"),
|
||||
|
||||
ERROR_CODE_NOT_LICENSED(22, "not licensed"),
|
||||
ERROR_CODE_ALREADY_FRIENDS(23, "already friends"),
|
||||
|
||||
ERROR_CODE_RECALL_TIME_EXPIRED(24, "time expired"),
|
||||
@@ -50,7 +51,7 @@ public enum ErrorCode {
|
||||
ERROR_CODE_SIGN_EXPIRED(243, "sign expired"),
|
||||
ERROR_CODE_AUTH_FAILURE(244, "auth failure"),
|
||||
ERROR_CODE_CLIENT_COUNT_OUT_OF_LIMIT(245, "client count out of limit"),
|
||||
ERROR_CODE_IN_BLACK_LIST(246, "user in balck list"),
|
||||
ERROR_CODE_IN_BLACK_LIST(246, "user in black list"),
|
||||
ERROR_CODE_FORBIDDEN_SEND_MSG(247, "forbidden send msg globally"),
|
||||
ERROR_CODE_NOT_RIGHT(248, "no right to operate"),
|
||||
ERROR_CODE_TIMEOUT(249, "timeout"),
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class ConferenceCreateEvent {
|
||||
public String userId;
|
||||
public String roomId;
|
||||
public String serverId;
|
||||
public String description;
|
||||
public String pin;
|
||||
public int max_publishers;
|
||||
public int bitrate;
|
||||
public boolean advance;
|
||||
public boolean recording;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class ConferenceDestroyEvent {
|
||||
public String userId;
|
||||
public String roomId;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class ConferenceJoinEvent {
|
||||
public String userId;
|
||||
public String roomId;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class ConferenceLeaveEvent {
|
||||
public String userId;
|
||||
public String roomId;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class ConferencePublishEvent {
|
||||
public String userId;
|
||||
public boolean video;
|
||||
public String roomId;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class ConferenceUnpublishEvent {
|
||||
public String userId;
|
||||
public String roomId;
|
||||
}
|
||||
@@ -27,6 +27,8 @@ public class InputDismissGroup extends InputGroupBase {
|
||||
}
|
||||
|
||||
public boolean isValide() {
|
||||
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ public class InputKickoffGroupMember extends InputGroupBase {
|
||||
}
|
||||
|
||||
public boolean isValide() {
|
||||
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator) || members == null || members.isEmpty())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ public class InputModifyGroupInfo extends InputGroupBase {
|
||||
private String value;
|
||||
|
||||
public boolean isValide() {
|
||||
return !StringUtil.isNullOrEmpty(group_id);
|
||||
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public String getGroup_id() {
|
||||
return group_id;
|
||||
|
||||
@@ -10,6 +10,7 @@ package cn.wildfirechat.pojos;
|
||||
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,6 +26,8 @@ public class InputQuitGroup extends InputGroupBase {
|
||||
}
|
||||
|
||||
public boolean isValide() {
|
||||
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ public class InputTransferGroup extends InputGroupBase {
|
||||
|
||||
|
||||
public boolean isValide() {
|
||||
if (StringUtil.isNullOrEmpty(group_id) || StringUtil.isNullOrEmpty(operator) || StringUtil.isNullOrEmpty(new_owner))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class InputVerifyApplicationUser {
|
||||
private String token;
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class OutputVerifyApplicationUser {
|
||||
private String userId;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class PojoConferenceCreate {
|
||||
public String roomId;
|
||||
public String description;
|
||||
public String pin;
|
||||
public int max_publishers;
|
||||
public int bitrate;
|
||||
public boolean advance;
|
||||
public boolean recording;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class PojoConferenceInfo {
|
||||
public String roomId;
|
||||
public String serverId;
|
||||
public String description;
|
||||
public int max_publishers;
|
||||
public int num_publishers;
|
||||
public int bitrate;
|
||||
public boolean advance;
|
||||
public boolean recording;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PojoConferenceInfoList {
|
||||
public PojoConferenceInfoList(List<PojoConferenceInfo> conferenceInfoList) {
|
||||
this.conferenceInfoList = conferenceInfoList;
|
||||
}
|
||||
|
||||
public PojoConferenceInfoList() {
|
||||
conferenceInfoList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<PojoConferenceInfo> conferenceInfoList;
|
||||
|
||||
public void addConferenceInfo(PojoConferenceInfo conferenceInfo) {
|
||||
this.conferenceInfoList.add(conferenceInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class PojoConferenceParticipant {
|
||||
public String userId;
|
||||
public boolean publishing;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PojoConferenceParticipantList {
|
||||
public PojoConferenceParticipantList(List<PojoConferenceParticipant> participantList) {
|
||||
this.participantList = participantList;
|
||||
}
|
||||
|
||||
public PojoConferenceParticipantList() {
|
||||
participantList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<PojoConferenceParticipant> participantList;
|
||||
|
||||
public void addConferenceInfo(PojoConferenceParticipant participant) {
|
||||
this.participantList.add(participant);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.64</version>
|
||||
<version>0.66</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
|
||||
@@ -130,6 +130,10 @@ group.visible_quit_or_kickoff_notification 0
|
||||
## 注意,修改本配置不会对已经同步的信息产生影响。
|
||||
#user.hide_properties 3,4
|
||||
|
||||
# 好友/好友请求/用户设置 这三类数据同步的最大条目数。之前是客户第一次登录时,会把所有的对应数据一次下载到客户端,但如果有特别多的信息,会导致无法同步到客户端,
|
||||
# 因此需要分段多次同步,此开关定义了每次同步的数据的条数。此需要客户端支持,客户端SDK在2021.5.25日后支持此功能。如果确认所有客户端都在这个日志之后才可以打开此设置。
|
||||
#sync.data_part_size 1000
|
||||
|
||||
#*********************************************************************
|
||||
# hazelcase configuration
|
||||
#*********************************************************************
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.64</version>
|
||||
<version>0.66</version>
|
||||
<name>Wildfire Chat</name>
|
||||
<description>Wildfire Chat Server</description>
|
||||
<inceptionYear>2019</inceptionYear>
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.64</version>
|
||||
<version>0.66</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.3</version>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
|
||||
//仅专业版支持,社区版不支持
|
||||
public class ChannelServiceApi {
|
||||
private ChannelHttpUtils httpUtils;
|
||||
private final ChannelHttpUtils httpUtils;
|
||||
|
||||
public ChannelServiceApi(String imurl, String channelId, String secret) {
|
||||
httpUtils = new ChannelHttpUtils(imurl, channelId, secret);
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package cn.wildfirechat.sdk;
|
||||
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
import cn.wildfirechat.sdk.utilities.ChannelHttpUtils;
|
||||
import cn.wildfirechat.sdk.utilities.RobotHttpUtils;
|
||||
|
||||
public class ChatConfig {
|
||||
public static void initAdmin(String url, String secret) {
|
||||
AdminHttpUtils.init(url, secret);
|
||||
}
|
||||
|
||||
public static void initRobot(String url, String robotId, String secret) {
|
||||
RobotHttpUtils.init(url, robotId, secret);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.wildfirechat.sdk;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.sdk.model.IMResult;
|
||||
import cn.wildfirechat.sdk.utilities.AdminHttpUtils;
|
||||
|
||||
public class ConferenceAdmin {
|
||||
public static IMResult<PojoConferenceInfoList> listConferences() throws Exception {
|
||||
String path = APIPath.Conference_List;
|
||||
return AdminHttpUtils.httpJsonPost(path, null, PojoConferenceInfoList.class);
|
||||
}
|
||||
|
||||
public static IMResult<PojoConferenceParticipantList> listParticipants(String roomId) throws Exception {
|
||||
String path = APIPath.Conference_List_Participant;
|
||||
return AdminHttpUtils.httpJsonPost(path, roomId, PojoConferenceParticipantList.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> createRoom(String roomId, String description, String pin, int maxPublisher, boolean advance, int bitrate, boolean recording) throws Exception {
|
||||
String path = APIPath.Conference_Create;
|
||||
PojoConferenceCreate create = new PojoConferenceCreate();
|
||||
create.roomId = roomId;
|
||||
create.description = description;
|
||||
create.pin = pin;
|
||||
create.max_publishers = maxPublisher;
|
||||
create.advance = advance;
|
||||
create.bitrate = bitrate;
|
||||
create.recording = recording;
|
||||
return AdminHttpUtils.httpJsonPost(path, create, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> destroy(String roomId) throws Exception {
|
||||
String path = APIPath.Conference_Destroy;
|
||||
return AdminHttpUtils.httpJsonPost(path, roomId, Void.class);
|
||||
}
|
||||
}
|
||||
@@ -43,9 +43,9 @@ public class Main {
|
||||
testSensitiveApi();
|
||||
if (commercialServer) {
|
||||
testDevice();
|
||||
testConference();
|
||||
}
|
||||
|
||||
|
||||
System.out.println("Congratulation, all admin test case passed!!!!!!!");
|
||||
}
|
||||
|
||||
@@ -133,7 +133,6 @@ public class Main {
|
||||
System.out.println("get user info by userId failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
InputOutputUserInfo updateUserInfo = new InputOutputUserInfo();
|
||||
updateUserInfo.setUserId(System.currentTimeMillis()+"");
|
||||
updateUserInfo.setDisplayName("updatedUserName");
|
||||
@@ -853,13 +852,14 @@ public class Main {
|
||||
static void testRobot() throws Exception {
|
||||
//初始化机器人API,注意端口是80,不是18080
|
||||
String robotId = "robot1";
|
||||
RobotHttpUtils.init("http://localhost", robotId, "123456");
|
||||
|
||||
RobotService robotService = new RobotService("http://localhost", robotId, "123456");
|
||||
|
||||
//***********************************************
|
||||
//**** 机器人API
|
||||
//***********************************************
|
||||
|
||||
IMResult<InputOutputUserInfo> userInfoIMResult = RobotService.getProfile(robotId);
|
||||
IMResult<InputOutputUserInfo> userInfoIMResult = robotService.getProfile(robotId);
|
||||
if(userInfoIMResult != null && userInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get profile success");
|
||||
} else {
|
||||
@@ -868,14 +868,14 @@ public class Main {
|
||||
}
|
||||
|
||||
String displayName = "testrobot"+System.currentTimeMillis();
|
||||
IMResult<Void> voidIMResult1 = RobotService.updateProfile(Modify_DisplayName, displayName);
|
||||
IMResult<Void> voidIMResult1 = robotService.updateProfile(Modify_DisplayName, displayName);
|
||||
if(voidIMResult1 != null && voidIMResult1.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("modify profile success");
|
||||
} else {
|
||||
System.out.println("modify profile failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
userInfoIMResult = RobotService.getProfile(robotId);
|
||||
userInfoIMResult = robotService.getProfile(robotId);
|
||||
if(userInfoIMResult != null && userInfoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && displayName.equals(userInfoIMResult.getResult().getDisplayName())) {
|
||||
System.out.println("get profile success");
|
||||
} else {
|
||||
@@ -884,7 +884,7 @@ public class Main {
|
||||
}
|
||||
|
||||
String robotCallback = "http://hellow123";
|
||||
voidIMResult1 = RobotService.setCallback(robotCallback);
|
||||
voidIMResult1 = robotService.setCallback(robotCallback);
|
||||
if(voidIMResult1 != null && voidIMResult1.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("set callback success");
|
||||
} else {
|
||||
@@ -892,7 +892,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<RobotCallbackPojo> callbackPojoIMResult = RobotService.getCallback();
|
||||
IMResult<RobotCallbackPojo> callbackPojoIMResult = robotService.getCallback();
|
||||
if(callbackPojoIMResult != null && callbackPojoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && robotCallback.equals(callbackPojoIMResult.getResult().getUrl())) {
|
||||
System.out.println("get callback success");
|
||||
} else {
|
||||
@@ -900,7 +900,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult1 = RobotService.deleteCallback();
|
||||
voidIMResult1 = robotService.deleteCallback();
|
||||
if(voidIMResult1 != null && voidIMResult1.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("delete callback success");
|
||||
} else {
|
||||
@@ -908,7 +908,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
callbackPojoIMResult = RobotService.getCallback();
|
||||
callbackPojoIMResult = robotService.getCallback();
|
||||
if(callbackPojoIMResult != null && callbackPojoIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS && StringUtil.isNullOrEmpty(callbackPojoIMResult.getResult().getUrl())) {
|
||||
System.out.println("get callback success");
|
||||
} else {
|
||||
@@ -923,7 +923,7 @@ public class Main {
|
||||
payload.setType(1);
|
||||
payload.setSearchableContent("hello world");
|
||||
|
||||
IMResult<SendMessageResult> resultRobotSendMessage = RobotService.sendMessage("robot1", conversation, payload);
|
||||
IMResult<SendMessageResult> resultRobotSendMessage = robotService.sendMessage("robot1", conversation, payload);
|
||||
if (resultRobotSendMessage != null && resultRobotSendMessage.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("robot send message success");
|
||||
} else {
|
||||
@@ -931,7 +931,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<InputOutputUserInfo> resultRobotGetUserInfo = RobotService.getUserInfo("userId1");
|
||||
IMResult<InputOutputUserInfo> resultRobotGetUserInfo = robotService.getUserInfo("userId1");
|
||||
if (resultRobotGetUserInfo != null && resultRobotGetUserInfo.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("robot get user info success");
|
||||
} else {
|
||||
@@ -960,7 +960,7 @@ public class Main {
|
||||
member3.setMember_id("user3");
|
||||
members.add(member3);
|
||||
|
||||
IMResult<OutputCreateGroupResult> resultCreateGroup = RobotService.createGroup(groupInfo, members, null, null);
|
||||
IMResult<OutputCreateGroupResult> resultCreateGroup = robotService.createGroup(groupInfo, members, null, null);
|
||||
if (resultCreateGroup != null && resultCreateGroup.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("create group success");
|
||||
} else {
|
||||
@@ -968,7 +968,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<PojoGroupInfo> resultGetGroupInfo = RobotService.getGroupInfo(groupInfo.getTarget_id());
|
||||
IMResult<PojoGroupInfo> resultGetGroupInfo = robotService.getGroupInfo(groupInfo.getTarget_id());
|
||||
if (resultGetGroupInfo != null && resultGetGroupInfo.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (groupInfo.getExtra().equals(resultGetGroupInfo.getResult().getExtra())
|
||||
&& groupInfo.getName().equals(resultGetGroupInfo.getResult().getName())
|
||||
@@ -983,7 +983,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
IMResult<Void> voidIMResult = RobotService.modifyGroupInfo(groupInfo.getTarget_id(), ProtoConstants.ModifyGroupInfoType.Modify_Group_Name,"HelloWorld", null, null);
|
||||
IMResult<Void> voidIMResult = robotService.modifyGroupInfo(groupInfo.getTarget_id(), ProtoConstants.ModifyGroupInfoType.Modify_Group_Name,"HelloWorld", null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("modify group success");
|
||||
} else {
|
||||
@@ -992,7 +992,7 @@ public class Main {
|
||||
}
|
||||
|
||||
|
||||
IMResult<OutputGroupMemberList> resultGetMembers = RobotService.getGroupMembers(groupInfo.getTarget_id());
|
||||
IMResult<OutputGroupMemberList> resultGetMembers = robotService.getGroupMembers(groupInfo.getTarget_id());
|
||||
if (resultGetMembers != null && resultGetMembers.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get group member success");
|
||||
} else {
|
||||
@@ -1004,7 +1004,7 @@ public class Main {
|
||||
m.setMember_id("user1");
|
||||
m.setAlias("hello user1");
|
||||
|
||||
voidIMResult = RobotService.addGroupMembers(groupInfo.getTarget_id(), Arrays.asList(m), null, null);
|
||||
voidIMResult = robotService.addGroupMembers(groupInfo.getTarget_id(), Arrays.asList(m), null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("add group member success");
|
||||
} else {
|
||||
@@ -1012,7 +1012,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult = RobotService.kickoffGroupMembers(groupInfo.getTarget_id(), Arrays.asList("user3"), null, null);
|
||||
voidIMResult = robotService.kickoffGroupMembers(groupInfo.getTarget_id(), Arrays.asList("user3"), null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("kickoff group member success");
|
||||
} else {
|
||||
@@ -1020,7 +1020,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult = RobotService.setGroupMemberAlias(groupInfo.getTarget_id(), "user3", "test user3", null, null);
|
||||
voidIMResult = robotService.setGroupMemberAlias(groupInfo.getTarget_id(), "user3", "test user3", null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("set group member alias success");
|
||||
} else {
|
||||
@@ -1029,7 +1029,7 @@ public class Main {
|
||||
}
|
||||
|
||||
if(commercialServer) {
|
||||
voidIMResult = RobotService.setGroupManager(groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), true, null, null);
|
||||
voidIMResult = robotService.setGroupManager(groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), true, null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("set group manager success");
|
||||
} else {
|
||||
@@ -1037,7 +1037,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult = RobotService.setGroupManager(groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), false, null, null);
|
||||
voidIMResult = robotService.setGroupManager(groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), false, null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("cancel group manager success");
|
||||
} else {
|
||||
@@ -1051,7 +1051,7 @@ public class Main {
|
||||
//仅专业版支持
|
||||
if (commercialServer) {
|
||||
//开启群成员禁言
|
||||
voidIMResult = RobotService.muteGroupMember(groupInfo.getTarget_id(), Arrays.asList("user5"), true, null, null);
|
||||
voidIMResult = robotService.muteGroupMember(groupInfo.getTarget_id(), Arrays.asList("user5"), true, null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("mute group member success");
|
||||
} else {
|
||||
@@ -1059,7 +1059,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
//关闭群成员禁言
|
||||
voidIMResult = RobotService.muteGroupMember(groupInfo.getTarget_id(), Arrays.asList("user5"), false, null, null);
|
||||
voidIMResult = robotService.muteGroupMember(groupInfo.getTarget_id(), Arrays.asList("user5"), false, null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("unmute group member success");
|
||||
} else {
|
||||
@@ -1068,7 +1068,7 @@ public class Main {
|
||||
}
|
||||
|
||||
//开启群成员白名单,当群全局禁言时,白名单用户可以发言
|
||||
voidIMResult = RobotService.allowGroupMember(groupInfo.getTarget_id(), Arrays.asList("user5"), true, null, null);
|
||||
voidIMResult = robotService.allowGroupMember(groupInfo.getTarget_id(), Arrays.asList("user5"), true, null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("allow group member success");
|
||||
} else {
|
||||
@@ -1077,7 +1077,7 @@ public class Main {
|
||||
}
|
||||
|
||||
//关闭群成员白名单
|
||||
voidIMResult = RobotService.allowGroupMember(groupInfo.getTarget_id(), Arrays.asList("user5"), false, null, null);
|
||||
voidIMResult = robotService.allowGroupMember(groupInfo.getTarget_id(), Arrays.asList("user5"), false, null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("unallow group member success");
|
||||
} else {
|
||||
@@ -1085,7 +1085,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
voidIMResult = RobotService.transferGroup(groupInfo.getTarget_id(), "user2", null, null);
|
||||
voidIMResult = robotService.transferGroup(groupInfo.getTarget_id(), "user2", null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("transfer success");
|
||||
} else {
|
||||
@@ -1093,7 +1093,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
resultGetGroupInfo = RobotService.getGroupInfo(groupInfo.getTarget_id());
|
||||
resultGetGroupInfo = robotService.getGroupInfo(groupInfo.getTarget_id());
|
||||
if (resultGetGroupInfo != null && resultGetGroupInfo.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if ("user2".equals(resultGetGroupInfo.getResult().getOwner())) {
|
||||
groupInfo.setOwner("user2");
|
||||
@@ -1106,7 +1106,7 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
voidIMResult = RobotService.quitGroup(groupInfo.getTarget_id(), null, null);
|
||||
voidIMResult = robotService.quitGroup(groupInfo.getTarget_id(), null, null);
|
||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("quit group success");
|
||||
} else {
|
||||
@@ -1184,6 +1184,8 @@ public class Main {
|
||||
ChannelServiceApi channelServiceApi = new ChannelServiceApi("http://localhost", resultCreateChannel.getResult().getTargetId(), secret);
|
||||
|
||||
|
||||
|
||||
if (commercialServer) {
|
||||
//3. 测试channel api功能
|
||||
IMResult<Void> resultVoid = channelServiceApi.subscribe("userId2");
|
||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
@@ -1200,6 +1202,7 @@ public class Main {
|
||||
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")) {
|
||||
System.out.println("get subscriber done");
|
||||
@@ -1231,7 +1234,7 @@ public class Main {
|
||||
System.out.println("get user info failure");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
MessagePayload payload = new MessagePayload();
|
||||
@@ -1352,4 +1355,61 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
会议相关接口,仅音视频高级版服务支持
|
||||
*/
|
||||
public static void testConference() throws Exception {
|
||||
IMResult<PojoConferenceInfoList> listResult = ConferenceAdmin.listConferences();
|
||||
if(listResult == null || listResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get conference list failure");
|
||||
System.exit(-1);
|
||||
} else {
|
||||
System.out.println("conference list " + listResult.getResult().conferenceInfoList);
|
||||
}
|
||||
|
||||
for (PojoConferenceInfo conferenceInfo:listResult.getResult().conferenceInfoList) {
|
||||
IMResult<Void> destroyResult = ConferenceAdmin.destroy(conferenceInfo.roomId);
|
||||
if(destroyResult == null || destroyResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("destroy room failure");
|
||||
System.exit(-1);
|
||||
} else {
|
||||
System.out.println("destroy room success");
|
||||
}
|
||||
}
|
||||
|
||||
listResult = ConferenceAdmin.listConferences();
|
||||
if(listResult == null || listResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get conference list failure");
|
||||
System.exit(-1);
|
||||
} else {
|
||||
System.out.println("conference list " + listResult.getResult().conferenceInfoList);
|
||||
}
|
||||
|
||||
IMResult<Void> createResult = ConferenceAdmin.createRoom("helloroomid", "hello room description", "123456", 20, false, 0, false);
|
||||
if(createResult == null || createResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("create conference list failure");
|
||||
System.exit(-1);
|
||||
} else {
|
||||
System.out.println("create conference");
|
||||
}
|
||||
|
||||
listResult = ConferenceAdmin.listConferences();
|
||||
if(listResult == null || listResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("get conference list failure");
|
||||
System.exit(-1);
|
||||
} else {
|
||||
System.out.println("conference list " + listResult.getResult().conferenceInfoList);
|
||||
}
|
||||
|
||||
for (PojoConferenceInfo conferenceInfo:listResult.getResult().conferenceInfoList) {
|
||||
IMResult<PojoConferenceParticipantList> listParticipantsResult = ConferenceAdmin.listParticipants(conferenceInfo.roomId);
|
||||
if(listParticipantsResult == null || listParticipantsResult.getErrorCode() != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("destroy room failure");
|
||||
System.exit(-1);
|
||||
} else {
|
||||
System.out.println("destroy room success");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,64 +9,70 @@ import cn.wildfirechat.sdk.utilities.RobotHttpUtils;
|
||||
import java.util.List;
|
||||
|
||||
public class RobotService {
|
||||
public static IMResult<SendMessageResult> sendMessage(String sender, Conversation conversation, MessagePayload payload) throws Exception {
|
||||
private final RobotHttpUtils robotHttpUtils;
|
||||
|
||||
public RobotService(String url, String robotId, String robotSecret) {
|
||||
robotHttpUtils = new RobotHttpUtils(url, robotId, robotSecret);
|
||||
}
|
||||
|
||||
public IMResult<SendMessageResult> sendMessage(String sender, Conversation conversation, MessagePayload payload) throws Exception {
|
||||
String path = APIPath.Robot_Message_Send;
|
||||
SendMessageData messageData = new SendMessageData();
|
||||
messageData.setSender(sender);
|
||||
messageData.setConv(conversation);
|
||||
messageData.setPayload(payload);
|
||||
return RobotHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
||||
return robotHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class);
|
||||
}
|
||||
|
||||
public static IMResult<InputOutputUserInfo> getUserInfo(String userId) throws Exception {
|
||||
public IMResult<InputOutputUserInfo> getUserInfo(String userId) throws Exception {
|
||||
String path = APIPath.Robot_User_Info;
|
||||
InputGetUserInfo getUserInfo = new InputGetUserInfo(userId, null, null);
|
||||
return RobotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
|
||||
return robotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
|
||||
}
|
||||
|
||||
public static IMResult<InputOutputUserInfo> getUserInfoByMobile(String phone) throws Exception {
|
||||
public IMResult<InputOutputUserInfo> getUserInfoByMobile(String phone) throws Exception {
|
||||
String path = APIPath.Robot_User_Info;
|
||||
InputGetUserInfo getUserInfo = new InputGetUserInfo(null, null, phone);
|
||||
return RobotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
|
||||
return robotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
|
||||
}
|
||||
|
||||
public static IMResult<InputOutputUserInfo> getUserInfoByName(String userName) throws Exception {
|
||||
public IMResult<InputOutputUserInfo> getUserInfoByName(String userName) throws Exception {
|
||||
String path = APIPath.Robot_User_Info;
|
||||
InputGetUserInfo getUserInfo = new InputGetUserInfo(null, userName, null);
|
||||
return RobotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
|
||||
return robotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> setCallback(String url) throws Exception {
|
||||
public IMResult<Void> setCallback(String url) throws Exception {
|
||||
String path = APIPath.Robot_Set_Callback;
|
||||
RobotCallbackPojo pojo = new RobotCallbackPojo();
|
||||
pojo.setUrl(url);
|
||||
return RobotHttpUtils.httpJsonPost(path, pojo, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, pojo, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<RobotCallbackPojo> getCallback() throws Exception {
|
||||
public IMResult<RobotCallbackPojo> getCallback() throws Exception {
|
||||
String path = APIPath.Robot_Get_Callback;
|
||||
return RobotHttpUtils.httpJsonPost(path, null, RobotCallbackPojo.class);
|
||||
return robotHttpUtils.httpJsonPost(path, null, RobotCallbackPojo.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> deleteCallback() throws Exception {
|
||||
public IMResult<Void> deleteCallback() throws Exception {
|
||||
String path = APIPath.Robot_Delete_Callback;
|
||||
return RobotHttpUtils.httpJsonPost(path, null, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, null, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<InputOutputUserInfo> getProfile(String robotId) throws Exception {
|
||||
public IMResult<InputOutputUserInfo> getProfile(String robotId) throws Exception {
|
||||
return getUserInfo(robotId);
|
||||
}
|
||||
|
||||
/*
|
||||
type可选范围为MyInfoType,注意不能修改电话号码,如果要修改电话号码请使用adminapi进行修改
|
||||
*/
|
||||
public static IMResult<Void> updateProfile(int/*MyInfoType*/ type, String value) throws Exception {
|
||||
public IMResult<Void> updateProfile(int/*MyInfoType*/ type, String value) throws Exception {
|
||||
String path = APIPath.Robot_Update_Profile;
|
||||
IntStringPairPojo pojo = new IntStringPairPojo(type, value);
|
||||
return RobotHttpUtils.httpJsonPost(path, pojo, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, pojo, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<OutputCreateGroupResult> createGroup(PojoGroupInfo group_info, List<PojoGroupMember> members, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<OutputCreateGroupResult> createGroup(PojoGroupInfo group_info, List<PojoGroupMember> members, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Create_Group;
|
||||
PojoGroup pojoGroup = new PojoGroup();
|
||||
pojoGroup.setGroup_info(group_info);
|
||||
@@ -76,37 +82,37 @@ public class RobotService {
|
||||
createGroup.setTo_lines(to_lines);
|
||||
createGroup.setNotify_message(notify_message);
|
||||
|
||||
return RobotHttpUtils.httpJsonPost(path, createGroup, OutputCreateGroupResult.class);
|
||||
return robotHttpUtils.httpJsonPost(path, createGroup, OutputCreateGroupResult.class);
|
||||
}
|
||||
|
||||
public static IMResult<PojoGroupInfo> getGroupInfo(String groupId) throws Exception {
|
||||
public IMResult<PojoGroupInfo> getGroupInfo(String groupId) throws Exception {
|
||||
String path = APIPath.Robot_Group_Get_Info;
|
||||
InputGetGroup input = new InputGetGroup();
|
||||
input.setGroupId(groupId);
|
||||
|
||||
return RobotHttpUtils.httpJsonPost(path, input, PojoGroupInfo.class);
|
||||
return robotHttpUtils.httpJsonPost(path, input, PojoGroupInfo.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> dismissGroup(String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> dismissGroup(String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Dismiss;
|
||||
InputDismissGroup dismissGroup = new InputDismissGroup();
|
||||
dismissGroup.setGroup_id(groupId);
|
||||
dismissGroup.setTo_lines(to_lines);
|
||||
dismissGroup.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, dismissGroup, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, dismissGroup, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> transferGroup(String groupId, String newOwner, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> transferGroup(String groupId, String newOwner, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Transfer;
|
||||
InputTransferGroup transferGroup = new InputTransferGroup();
|
||||
transferGroup.setGroup_id(groupId);
|
||||
transferGroup.setNew_owner(newOwner);
|
||||
transferGroup.setTo_lines(to_lines);
|
||||
transferGroup.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, transferGroup, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, transferGroup, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> modifyGroupInfo(String groupId, /*ModifyGroupInfoType*/int type, String value, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> modifyGroupInfo(String groupId, /*ModifyGroupInfoType*/int type, String value, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Modify_Info;
|
||||
InputModifyGroupInfo modifyGroupInfo = new InputModifyGroupInfo();
|
||||
modifyGroupInfo.setGroup_id(groupId);
|
||||
@@ -114,28 +120,28 @@ public class RobotService {
|
||||
modifyGroupInfo.setType(type);
|
||||
modifyGroupInfo.setValue(value);
|
||||
modifyGroupInfo.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, modifyGroupInfo, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, modifyGroupInfo, Void.class);
|
||||
}
|
||||
|
||||
|
||||
public static IMResult<OutputGroupMemberList> getGroupMembers(String groupId) throws Exception {
|
||||
public IMResult<OutputGroupMemberList> getGroupMembers(String groupId) throws Exception {
|
||||
String path = APIPath.Robot_Group_Member_List;
|
||||
InputGetGroup input = new InputGetGroup();
|
||||
input.setGroupId(groupId);
|
||||
return RobotHttpUtils.httpJsonPost(path, input, OutputGroupMemberList.class);
|
||||
return robotHttpUtils.httpJsonPost(path, input, OutputGroupMemberList.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> addGroupMembers(String groupId, List<PojoGroupMember> groupMembers, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> addGroupMembers(String groupId, List<PojoGroupMember> groupMembers, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Member_Add;
|
||||
InputAddGroupMember addGroupMember = new InputAddGroupMember();
|
||||
addGroupMember.setGroup_id(groupId);
|
||||
addGroupMember.setMembers(groupMembers);
|
||||
addGroupMember.setTo_lines(to_lines);
|
||||
addGroupMember.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> setGroupManager(String groupId, List<String> groupMemberIds, boolean isManager, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> setGroupManager(String groupId, List<String> groupMemberIds, boolean isManager, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Set_Manager;
|
||||
InputSetGroupManager addGroupMember = new InputSetGroupManager();
|
||||
addGroupMember.setGroup_id(groupId);
|
||||
@@ -143,10 +149,10 @@ public class RobotService {
|
||||
addGroupMember.setIs_manager(isManager);
|
||||
addGroupMember.setTo_lines(to_lines);
|
||||
addGroupMember.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> muteGroupMember(String groupId, List<String> groupMemberIds, boolean isMute, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> muteGroupMember(String groupId, List<String> groupMemberIds, boolean isMute, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Mute_Member;
|
||||
InputMuteGroupMember addGroupMember = new InputMuteGroupMember();
|
||||
addGroupMember.setGroup_id(groupId);
|
||||
@@ -154,10 +160,10 @@ public class RobotService {
|
||||
addGroupMember.setIs_manager(isMute);
|
||||
addGroupMember.setTo_lines(to_lines);
|
||||
addGroupMember.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> allowGroupMember(String groupId, List<String> groupMemberIds, boolean isAllow, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> allowGroupMember(String groupId, List<String> groupMemberIds, boolean isAllow, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Allow_Member;
|
||||
InputMuteGroupMember addGroupMember = new InputMuteGroupMember();
|
||||
addGroupMember.setGroup_id(groupId);
|
||||
@@ -165,29 +171,29 @@ public class RobotService {
|
||||
addGroupMember.setIs_manager(isAllow);
|
||||
addGroupMember.setTo_lines(to_lines);
|
||||
addGroupMember.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> kickoffGroupMembers(String groupId, List<String> groupMemberIds, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> kickoffGroupMembers(String groupId, List<String> groupMemberIds, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Member_Kickoff;
|
||||
InputKickoffGroupMember kickoffGroupMember = new InputKickoffGroupMember();
|
||||
kickoffGroupMember.setGroup_id(groupId);
|
||||
kickoffGroupMember.setMembers(groupMemberIds);
|
||||
kickoffGroupMember.setTo_lines(to_lines);
|
||||
kickoffGroupMember.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, kickoffGroupMember, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, kickoffGroupMember, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> quitGroup(String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> quitGroup(String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Member_Quit;
|
||||
InputQuitGroup quitGroup = new InputQuitGroup();
|
||||
quitGroup.setGroup_id(groupId);
|
||||
quitGroup.setTo_lines(to_lines);
|
||||
quitGroup.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, quitGroup, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, quitGroup, Void.class);
|
||||
}
|
||||
|
||||
public static IMResult<Void> setGroupMemberAlias(String groupId, String memberId, String alias, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
public IMResult<Void> setGroupMemberAlias(String groupId, String memberId, String alias, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
|
||||
String path = APIPath.Robot_Group_Set_Member_Alias;
|
||||
InputSetGroupMemberAlias input = new InputSetGroupMemberAlias();
|
||||
input.setGroup_id(groupId);
|
||||
@@ -195,6 +201,6 @@ public class RobotService {
|
||||
input.setAlias(alias);
|
||||
input.setTo_lines(to_lines);
|
||||
input.setNotify_message(notify_message);
|
||||
return RobotHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
return robotHttpUtils.httpJsonPost(path, input, Void.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,23 +23,24 @@ import java.nio.charset.Charset;
|
||||
public class RobotHttpUtils {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RobotHttpUtils.class);
|
||||
|
||||
private static String url;
|
||||
private static String robotId;
|
||||
private static String robotSecret;
|
||||
private final String url;
|
||||
private final String robotId;
|
||||
private final String robotSecret;
|
||||
|
||||
public static void init(String url, String robotId, String secret) {
|
||||
RobotHttpUtils.url = url;
|
||||
RobotHttpUtils.robotId = robotId;
|
||||
RobotHttpUtils.robotSecret = secret;
|
||||
public RobotHttpUtils(String url, String robotId, String robotSecret) {
|
||||
this.url = url;
|
||||
this.robotId = robotId;
|
||||
this.robotSecret = robotSecret;
|
||||
}
|
||||
|
||||
public static <T> IMResult<T> httpJsonPost(String path, Object object, Class<T> clazz) throws Exception{
|
||||
|
||||
public <T> IMResult<T> httpJsonPost(String path, Object object, Class<T> clazz) throws Exception{
|
||||
if (isNullOrEmpty(url) || isNullOrEmpty(path)) {
|
||||
LOG.error("Not init IM SDK correctly. Do you forget init it?");
|
||||
throw new Exception("SDK url or secret lack!");
|
||||
}
|
||||
|
||||
String url = RobotHttpUtils.url + path;
|
||||
String url = this.url + path;
|
||||
HttpPost post = null;
|
||||
try {
|
||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
Reference in New Issue
Block a user