From d751a7080bfd56a43c528fbf102d6704f6a7a2bb Mon Sep 17 00:00:00 2001 From: heavyrian2012 Date: Fri, 21 Jun 2024 16:45:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Mesh=E7=9B=B8=E5=85=B3SDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- broker/migrate/h2/V49__add_domain_table.sql | 13 + .../migrate/mysql/V56__add_domain_table.sql | 16 ++ .../java/cn/wildfirechat/common/APIPath.java | 15 ++ .../cn/wildfirechat/pojos/InputGroupBase.java | 9 + .../pojos/InputHandleFriendRequest.java | 50 ++++ .../cn/wildfirechat/pojos/InputIntValue.java | 13 + .../pojos/InputOutputDomainInfo.java | 85 +++++++ .../pojos/InputOutputDomainInfoList.java | 24 ++ .../wildfirechat/pojos/InputStringValue.java | 13 + .../cn/wildfirechat/pojos/PojoGroupInfo.java | 27 +++ .../wildfirechat/pojos/PojoGroupInfoList.java | 23 ++ .../wildfirechat/pojos/PojoGroupMember.java | 9 + .../wildfirechat/pojos/RecallMessageData.java | 9 + .../wildfirechat/pojos/SendMessageData.java | 9 + .../pojos/UpdateMessageContentData.java | 9 + .../pojos/mesh/MeshRestResult.java | 139 +++++++++++ .../pojos/mesh/PojoAddFriendReq.java | 8 + .../pojos/mesh/PojoAddGroupMember.java | 44 ++++ .../pojos/mesh/PojoDismissGroup.java | 31 +++ .../pojos/mesh/PojoGroupUpdated.java | 36 +++ .../mesh/PojoHandleFriendRequestReq.java | 8 + .../pojos/mesh/PojoKickoffGroupMember.java | 42 ++++ .../pojos/mesh/PojoModifyGroupInfo.java | 49 ++++ .../pojos/mesh/PojoPublishMessageReq.java | 13 + .../pojos/mesh/PojoQuitGroup.java | 31 +++ .../pojos/mesh/PojoRecallMessageReq.java | 8 + .../pojos/mesh/PojoSearchUserReq.java | 40 +++ .../pojos/mesh/PojoSearchUserRes.java | 26 ++ .../pojos/mesh/PojoSendMessageReq.java | 10 + .../wildfirechat/pojos/mesh/PojoString.java | 22 ++ .../pojos/mesh/PojoStringList.java | 24 ++ .../pojos/mesh/PojoTransferGroup.java | 40 +++ .../pojos/mesh/PojoUserConferenceEvent.java | 9 + .../pojos/mesh/PojoUserConferenceRequest.java | 12 + .../mesh/PojoUserConferenceResponse.java | 5 + .../java/cn/wildfirechat/sdk/GroupAdmin.java | 5 + .../java/cn/wildfirechat/sdk/MeshAdmin.java | 229 ++++++++++++++++++ .../wildfirechat/sdk/utilities/JsonUtils.java | 17 ++ 38 files changed, 1172 insertions(+) create mode 100755 broker/migrate/h2/V49__add_domain_table.sql create mode 100755 broker/migrate/mysql/V56__add_domain_table.sql create mode 100755 common/src/main/java/cn/wildfirechat/pojos/InputHandleFriendRequest.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/InputIntValue.java create mode 100755 common/src/main/java/cn/wildfirechat/pojos/InputOutputDomainInfo.java create mode 100755 common/src/main/java/cn/wildfirechat/pojos/InputOutputDomainInfoList.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/InputStringValue.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/PojoGroupInfoList.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/MeshRestResult.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoAddFriendReq.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoAddGroupMember.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoDismissGroup.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoGroupUpdated.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoHandleFriendRequestReq.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoKickoffGroupMember.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoModifyGroupInfo.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoPublishMessageReq.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoQuitGroup.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoRecallMessageReq.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSearchUserReq.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSearchUserRes.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSendMessageReq.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoString.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoStringList.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoTransferGroup.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceEvent.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceRequest.java create mode 100644 common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceResponse.java create mode 100644 sdk/src/main/java/cn/wildfirechat/sdk/MeshAdmin.java diff --git a/broker/migrate/h2/V49__add_domain_table.sql b/broker/migrate/h2/V49__add_domain_table.sql new file mode 100755 index 00000000..0a2ec6a0 --- /dev/null +++ b/broker/migrate/h2/V49__add_domain_table.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS `t_domain`; +CREATE TABLE `t_domain` ( + `_domain_id` varchar(64) NOT NULL PRIMARY KEY, + `_name` varchar(64) NOT NULL, + `_desc` varchar(256) DEFAULT '', + `_email` varchar(64) DEFAULT '', + `_tel` varchar(64) DEFAULT '', + `_address` varchar(64) DEFAULT '', + `_extra` varchar(1024) DEFAULT '', + `_dt` bigint(20) NOT NULL +); + +alter table `t_user` add column `_external` tinyint DEFAULT 0; diff --git a/broker/migrate/mysql/V56__add_domain_table.sql b/broker/migrate/mysql/V56__add_domain_table.sql new file mode 100755 index 00000000..5b8ca17a --- /dev/null +++ b/broker/migrate/mysql/V56__add_domain_table.sql @@ -0,0 +1,16 @@ +DROP TABLE IF EXISTS `t_domain`; +CREATE TABLE `t_domain` ( + `_domain_id` varchar(128) NOT NULL PRIMARY KEY, + `_name` varchar(64) NOT NULL, + `_desc` varchar(256) DEFAULT '', + `_email` varchar(64) DEFAULT '', + `_tel` varchar(64) DEFAULT '', + `_address` varchar(64) DEFAULT '', + `_extra` varchar(1024) DEFAULT '', + `_dt` bigint(20) NOT NULL +) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8mb4 +COLLATE = utf8mb4_unicode_ci; + +alter table `t_user` add column `_external` tinyint DEFAULT 0; diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index 576cec3a..4346d57f 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -17,9 +17,15 @@ public interface APIPath { String Sensitive_Del = "/admin/sensitive/del"; String Sensitive_Query = "/admin/sensitive/query"; + String Create_Domain = "/admin/domain/create"; + String Get_Domain = "/admin/domain/get"; + String Destroy_Domain = "/admin/domain/destroy"; + String List_Domain = "/admin/domain/list"; + String Create_User = "/admin/user/create"; String Update_User = "/admin/user/update"; String Destroy_User = "/admin/user/destroy"; + String Search_User = "/admin/user/search_user"; String Create_Robot = "/admin/robot/create"; String CreateOrUpdate_Device = "/admin/device/create"; String Get_Device = "/admin/device/get"; @@ -27,6 +33,7 @@ public interface APIPath { String User_Get_Token = "/admin/user/get_token"; String User_Update_Block_Status = "/admin/user/update_block_status"; String User_Get_Info = "/admin/user/get_info"; + String User_Batch_Get_Infos = "/admin/user/batch_get_infos"; String User_Get_Email_Info = "/admin/user/get_info_by_email"; String User_Get_All = "/admin/user/all"; String User_Get_Robot_Info = "/admin/user/get_robot_info"; @@ -52,7 +59,10 @@ public interface APIPath { String Friend_Get_Requests = "/admin/friend/get_requests"; String Relation_Get = "/admin/relation/get"; + String Handle_Friend_Send_Request = "/admin/friend/handle_send_request"; + String Msg_Send = "/admin/message/send"; + String Msg_Publish = "/admin/message/publish"; String Msg_Recall = "/admin/message/recall"; String Msg_Delete = "/admin/message/delete"; String Msg_Update = "/admin/message/update"; @@ -70,6 +80,7 @@ public interface APIPath { String Group_Dismiss = "/admin/group/del"; String Group_Transfer = "/admin/group/transfer"; String Group_Get_Info = "/admin/group/get_info"; + String Group_Batch_Info = "/admin/group/batch_infos"; String Group_Modify_Info = "/admin/group/modify"; String Group_Member_List = "/admin/group/member/list"; String Group_Member_Get = "/admin/group/member/get"; @@ -85,6 +96,10 @@ public interface APIPath { String Group_Set_Member_Extra = "/admin/group/member/set_extra"; String Get_Common_Groups = "/admin/group/common_group"; + String Sync_Group = "/admin/mesh/group_sync"; + String Conference_User_Request = "/admin/conference/user_request"; + String Conference_User_Event = "/admin/conference/user_event"; + String Create_Channel = "/admin/channel/create"; String Destroy_Channel = "/admin/channel/destroy"; String Get_Channel_Info = "/admin/channel/get"; diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputGroupBase.java b/common/src/main/java/cn/wildfirechat/pojos/InputGroupBase.java index 62584825..d6a12054 100755 --- a/common/src/main/java/cn/wildfirechat/pojos/InputGroupBase.java +++ b/common/src/main/java/cn/wildfirechat/pojos/InputGroupBase.java @@ -15,6 +15,7 @@ public class InputGroupBase { public String operator; public List to_lines; public MessagePayload notify_message; + private boolean isMeshMessage; public String getOperator() { return operator; @@ -39,4 +40,12 @@ public class InputGroupBase { public void setNotify_message(MessagePayload notify_message) { this.notify_message = notify_message; } + + public boolean isMeshMessage() { + return isMeshMessage; + } + + public void setMeshMessage(boolean meshMessage) { + isMeshMessage = meshMessage; + } } diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputHandleFriendRequest.java b/common/src/main/java/cn/wildfirechat/pojos/InputHandleFriendRequest.java new file mode 100755 index 00000000..39f34445 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/InputHandleFriendRequest.java @@ -0,0 +1,50 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * 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 InputHandleFriendRequest { + private String userId; + private String friendUid; + private int status; + private boolean force; + + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getFriendUid() { + return friendUid; + } + + public void setFriendUid(String friendUid) { + this.friendUid = friendUid; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public boolean isForce() { + return force; + } + + public void setForce(boolean force) { + this.force = force; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputIntValue.java b/common/src/main/java/cn/wildfirechat/pojos/InputIntValue.java new file mode 100644 index 00000000..72080a10 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/InputIntValue.java @@ -0,0 +1,13 @@ +package cn.wildfirechat.pojos; + +public class InputIntValue { + public int value; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputOutputDomainInfo.java b/common/src/main/java/cn/wildfirechat/pojos/InputOutputDomainInfo.java new file mode 100755 index 00000000..20299e6f --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/InputOutputDomainInfo.java @@ -0,0 +1,85 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * 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 InputOutputDomainInfo { + public String domainId; + public String name; + public String desc; + public String email; + public String tel; + public String address; + public String extra; + public long dt; + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + 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 getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getExtra() { + return extra; + } + + public void setExtra(String extra) { + this.extra = extra; + } + + public long getDt() { + return dt; + } + + public void setDt(long dt) { + this.dt = dt; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputOutputDomainInfoList.java b/common/src/main/java/cn/wildfirechat/pojos/InputOutputDomainInfoList.java new file mode 100755 index 00000000..feb6ef81 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/InputOutputDomainInfoList.java @@ -0,0 +1,24 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package cn.wildfirechat.pojos; + + +import java.util.List; + +public class InputOutputDomainInfoList { + public List infos; + + public List getInfos() { + return infos; + } + + public void setInfos(List infos) { + this.infos = infos; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/InputStringValue.java b/common/src/main/java/cn/wildfirechat/pojos/InputStringValue.java new file mode 100644 index 00000000..bf8242ad --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/InputStringValue.java @@ -0,0 +1,13 @@ +package cn.wildfirechat.pojos; + +public class InputStringValue { + public String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/PojoGroupInfo.java b/common/src/main/java/cn/wildfirechat/pojos/PojoGroupInfo.java index f5d92b0b..e0c61e11 100644 --- a/common/src/main/java/cn/wildfirechat/pojos/PojoGroupInfo.java +++ b/common/src/main/java/cn/wildfirechat/pojos/PojoGroupInfo.java @@ -14,6 +14,7 @@ public class PojoGroupInfo { String portrait; String owner; int type; + int member_count; String extra; int mute; int join_type; @@ -23,6 +24,8 @@ public class PojoGroupInfo { int history_message; boolean super_group; boolean deleted; + long update_dt; + long member_update_dt; public String getTarget_id() { return target_id; @@ -135,4 +138,28 @@ public class PojoGroupInfo { public void setDeleted(boolean deleted) { this.deleted = deleted; } + + public long getUpdate_dt() { + return update_dt; + } + + public void setUpdate_dt(long update_dt) { + this.update_dt = update_dt; + } + + public int getMember_count() { + return member_count; + } + + public void setMember_count(int member_count) { + this.member_count = member_count; + } + + public long getMember_update_dt() { + return member_update_dt; + } + + public void setMember_update_dt(long member_update_dt) { + this.member_update_dt = member_update_dt; + } } diff --git a/common/src/main/java/cn/wildfirechat/pojos/PojoGroupInfoList.java b/common/src/main/java/cn/wildfirechat/pojos/PojoGroupInfoList.java new file mode 100644 index 00000000..6610dcc4 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/PojoGroupInfoList.java @@ -0,0 +1,23 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package cn.wildfirechat.pojos; + +import java.util.List; + +public class PojoGroupInfoList { + public List groupInfoList; + + public List getGroupInfoList() { + return groupInfoList; + } + + public void setGroupInfoList(List groupInfoList) { + this.groupInfoList = groupInfoList; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/PojoGroupMember.java b/common/src/main/java/cn/wildfirechat/pojos/PojoGroupMember.java index 8eca1592..3b7ba536 100644 --- a/common/src/main/java/cn/wildfirechat/pojos/PojoGroupMember.java +++ b/common/src/main/java/cn/wildfirechat/pojos/PojoGroupMember.java @@ -13,6 +13,7 @@ public class PojoGroupMember { String alias; int type; String extra; + long updateDt; long createDt; public String getMember_id() { @@ -47,6 +48,14 @@ public class PojoGroupMember { this.extra = extra; } + public long getUpdateDt() { + return updateDt; + } + + public void setUpdateDt(long updateDt) { + this.updateDt = updateDt; + } + public long getCreateDt() { return createDt; } diff --git a/common/src/main/java/cn/wildfirechat/pojos/RecallMessageData.java b/common/src/main/java/cn/wildfirechat/pojos/RecallMessageData.java index 0680b4b8..02f12404 100644 --- a/common/src/main/java/cn/wildfirechat/pojos/RecallMessageData.java +++ b/common/src/main/java/cn/wildfirechat/pojos/RecallMessageData.java @@ -14,6 +14,7 @@ import io.netty.util.internal.StringUtil; public class RecallMessageData { private String operator; private long messageUid; + private boolean isUserRecall; public String getOperator() { return operator; @@ -30,4 +31,12 @@ public class RecallMessageData { public void setMessageUid(long messageUid) { this.messageUid = messageUid; } + + public boolean isUserRecall() { + return isUserRecall; + } + + public void setUserRecall(boolean userRecall) { + isUserRecall = userRecall; + } } diff --git a/common/src/main/java/cn/wildfirechat/pojos/SendMessageData.java b/common/src/main/java/cn/wildfirechat/pojos/SendMessageData.java index 697c1322..de5ee254 100644 --- a/common/src/main/java/cn/wildfirechat/pojos/SendMessageData.java +++ b/common/src/main/java/cn/wildfirechat/pojos/SendMessageData.java @@ -19,6 +19,7 @@ public class SendMessageData { private Conversation conv; private MessagePayload payload; private List toUsers; + private boolean isMeshMessage; public String getSender() { return sender; @@ -52,6 +53,14 @@ public class SendMessageData { this.toUsers = toUsers; } + public boolean isMeshMessage() { + return isMeshMessage; + } + + public void setMeshMessage(boolean meshMessage) { + isMeshMessage = meshMessage; + } + public static boolean isValide(SendMessageData sendMessageData) { if(sendMessageData == null || sendMessageData.getConv() == null || diff --git a/common/src/main/java/cn/wildfirechat/pojos/UpdateMessageContentData.java b/common/src/main/java/cn/wildfirechat/pojos/UpdateMessageContentData.java index 82fcfbe4..1a5e67b0 100644 --- a/common/src/main/java/cn/wildfirechat/pojos/UpdateMessageContentData.java +++ b/common/src/main/java/cn/wildfirechat/pojos/UpdateMessageContentData.java @@ -14,6 +14,7 @@ public class UpdateMessageContentData { private MessagePayload payload; private int distribute; private int updateTimestamp; + private int meshLocal; public String getOperator() { return operator; @@ -54,4 +55,12 @@ public class UpdateMessageContentData { public void setUpdateTimestamp(int updateTimestamp) { this.updateTimestamp = updateTimestamp; } + + public int getMeshLocal() { + return meshLocal; + } + + public void setMeshLocal(int meshLocal) { + this.meshLocal = meshLocal; + } } diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/MeshRestResult.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/MeshRestResult.java new file mode 100644 index 00000000..475a0555 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/MeshRestResult.java @@ -0,0 +1,139 @@ +package cn.wildfirechat.pojos.mesh; + +import com.google.gson.Gson; + +public class MeshRestResult { + private static Gson gson = new Gson(); + public enum MeshRestCode { + SUCCESS(0, "success"), + ERROR_INVALID_MOBILE(1, "无效的电话号码"), + ERROR_SEND_SMS_OVER_FREQUENCY(3, "请求验证码太频繁"), + ERROR_SERVER_ERROR(4, "服务器异常"), + ERROR_CODE_EXPIRED(5, "验证码已过期"), + ERROR_CODE_INCORRECT(6, "验证码或密码错误"), + ERROR_SERVER_CONFIG_ERROR(7, "服务器配置错误"), + ERROR_SESSION_EXPIRED(8, "会话不存在或已过期"), + ERROR_SESSION_NOT_VERIFIED(9, "会话没有验证"), + ERROR_SESSION_NOT_SCANED(10, "会话没有被扫码"), + ERROR_SERVER_NOT_IMPLEMENT(11, "功能没有实现"), + ERROR_GROUP_ANNOUNCEMENT_NOT_EXIST(12, "群公告不存在"), + ERROR_NOT_LOGIN(13, "没有登录"), + ERROR_NO_RIGHT(14, "没有权限"), + ERROR_INVALID_PARAMETER(15, "无效参数"), + ERROR_NOT_EXIST(16, "对象不存在"), + ERROR_USER_NAME_ALREADY_EXIST(17, "用户名已经存在"), + ERROR_SESSION_CANCELED(18, "会话已经取消"), + ERROR_PASSWORD_INCORRECT(19, "密码错误"), + ERROR_FAILURE_TOO_MUCH_TIMES(20, "密码错误次数太多,请等5分钟再试试"), + ERROR_USER_FORBIDDEN(21, "用户被封禁"); + public int code; + public String msg; + + MeshRestCode(int code, String msg) { + this.code = code; + this.msg = msg; + } + + } + private int remote_im_code; + private int remote_mesh_code; + private int local_mesh_code; + private String error_message; + private T result; + + @Override + public String toString() { + return gson.toJson(this); + } + + public static MeshRestResult ok() { + return new MeshRestResult(); + } + + public static MeshRestResult ok(Object object) { + return new MeshRestResult(object); + } + + public static MeshRestResult remoteIMError(int code, String message) { + MeshRestResult r = new MeshRestResult(); + r.remote_im_code = code; + r.error_message = message; + return r; + } + + public static MeshRestResult remoteMeshError(int code, String message) { + MeshRestResult r = new MeshRestResult(); + r.remote_mesh_code = code; + r.error_message = message; + return r; + } + + public MeshRestResult addRemoteMeshError(int code, String message) { + MeshRestResult r = new MeshRestResult(); + remote_mesh_code = code; + error_message = message; + return this; + } + + public static MeshRestResult localMeshError(int code, String message) { + MeshRestResult r = new MeshRestResult(); + r.local_mesh_code = code; + r.error_message = message; + return r; + } + + public MeshRestResult addLocalMeshError(int code, String message) { + local_mesh_code = code; + error_message = message; + return this; + } + + + public MeshRestResult() { + + } + + public MeshRestResult(T object) { + result = object; + } + + public T getResult() { + return result; + } + + public void setResult(T result) { + this.result = result; + } + + public int getRemote_im_code() { + return remote_im_code; + } + + public void setRemote_im_code(int remote_im_code) { + this.remote_im_code = remote_im_code; + } + + public int getRemote_mesh_code() { + return remote_mesh_code; + } + + public void setRemote_mesh_code(int remote_mesh_code) { + this.remote_mesh_code = remote_mesh_code; + } + + public int getLocal_mesh_code() { + return local_mesh_code; + } + + public void setLocal_mesh_code(int local_mesh_code) { + this.local_mesh_code = local_mesh_code; + } + + public String getError_message() { + return error_message; + } + + public void setError_message(String error_message) { + this.error_message = error_message; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoAddFriendReq.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoAddFriendReq.java new file mode 100644 index 00000000..6d33942e --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoAddFriendReq.java @@ -0,0 +1,8 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoAddFriendReq { + public String fromUserId; + public String reason; + public String targetUserId; + public String domainId; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoAddGroupMember.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoAddGroupMember.java new file mode 100644 index 00000000..90840095 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoAddGroupMember.java @@ -0,0 +1,44 @@ +package cn.wildfirechat.pojos.mesh; + +import cn.wildfirechat.pojos.PojoGroupMember; + +import java.util.List; + +public class PojoAddGroupMember { + public String domainId; + public String operator; + public String group_id; + public List members; + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getGroup_id() { + return group_id; + } + + public void setGroup_id(String group_id) { + this.group_id = group_id; + } + + public List getMembers() { + return members; + } + + public void setMembers(List members) { + this.members = members; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoDismissGroup.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoDismissGroup.java new file mode 100644 index 00000000..27ba6b42 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoDismissGroup.java @@ -0,0 +1,31 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoDismissGroup { + public String domainId; + public String operator; + public String group_id; + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getGroup_id() { + return group_id; + } + + public void setGroup_id(String group_id) { + this.group_id = group_id; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoGroupUpdated.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoGroupUpdated.java new file mode 100644 index 00000000..753cee24 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoGroupUpdated.java @@ -0,0 +1,36 @@ +package cn.wildfirechat.pojos.mesh; + +import cn.wildfirechat.pojos.PojoGroupInfo; +import cn.wildfirechat.pojos.PojoGroupMember; + +import java.util.List; + +public class PojoGroupUpdated { + public List domainIds; + public PojoGroupInfo groupInfo; + public List members; + + public List getDomainIds() { + return domainIds; + } + + public void setDomainIds(List domainIds) { + this.domainIds = domainIds; + } + + public PojoGroupInfo getGroupInfo() { + return groupInfo; + } + + public void setGroupInfo(PojoGroupInfo groupInfo) { + this.groupInfo = groupInfo; + } + + public List getMembers() { + return members; + } + + public void setMembers(List members) { + this.members = members; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoHandleFriendRequestReq.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoHandleFriendRequestReq.java new file mode 100644 index 00000000..c3f7b45f --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoHandleFriendRequestReq.java @@ -0,0 +1,8 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoHandleFriendRequestReq { + public String userId; + public int status; + public String targetUserId; + public String domainId; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoKickoffGroupMember.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoKickoffGroupMember.java new file mode 100644 index 00000000..ce3ce31f --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoKickoffGroupMember.java @@ -0,0 +1,42 @@ +package cn.wildfirechat.pojos.mesh; + +import java.util.List; + +public class PojoKickoffGroupMember { + public String domainId; + public String operator; + public String group_id; + public List members; + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getGroup_id() { + return group_id; + } + + public void setGroup_id(String group_id) { + this.group_id = group_id; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + public List getMembers() { + return members; + } + + public void setMembers(List members) { + this.members = members; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoModifyGroupInfo.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoModifyGroupInfo.java new file mode 100644 index 00000000..dfc85a2d --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoModifyGroupInfo.java @@ -0,0 +1,49 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoModifyGroupInfo { + public String domainId; + public String operator; + public String group_id; + public int type; + public String value; + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getGroup_id() { + return group_id; + } + + public void setGroup_id(String group_id) { + this.group_id = group_id; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoPublishMessageReq.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoPublishMessageReq.java new file mode 100644 index 00000000..812fe5eb --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoPublishMessageReq.java @@ -0,0 +1,13 @@ +package cn.wildfirechat.pojos.mesh; + +import cn.wildfirechat.pojos.SendMessageData; + +import java.util.List; + +public class PojoPublishMessageReq { + public SendMessageData messageData; + public List receivers; + public String domainId; + public long messageId; + public boolean republish; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoQuitGroup.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoQuitGroup.java new file mode 100644 index 00000000..3fdc325c --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoQuitGroup.java @@ -0,0 +1,31 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoQuitGroup { + public String domainId; + public String operator; + public String group_id; + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getGroup_id() { + return group_id; + } + + public void setGroup_id(String group_id) { + this.group_id = group_id; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoRecallMessageReq.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoRecallMessageReq.java new file mode 100644 index 00000000..6f661980 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoRecallMessageReq.java @@ -0,0 +1,8 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoRecallMessageReq { + public String domainId; + public long messageId; + public String operator; + public boolean isSenderRecall; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSearchUserReq.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSearchUserReq.java new file mode 100644 index 00000000..aaec73e8 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSearchUserReq.java @@ -0,0 +1,40 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoSearchUserReq { + public String keyword; + public int searchType; + public int page; + public String domainId; + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + public int getSearchType() { + return searchType; + } + + public void setSearchType(int searchType) { + this.searchType = searchType; + } + + public int getPage() { + return page; + } + + public void setPage(int page) { + this.page = page; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSearchUserRes.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSearchUserRes.java new file mode 100644 index 00000000..d2d6e85f --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSearchUserRes.java @@ -0,0 +1,26 @@ +package cn.wildfirechat.pojos.mesh; + +import cn.wildfirechat.pojos.InputOutputUserInfo; + +import java.util.List; + +public class PojoSearchUserRes { + public List userInfos; + public String keyword; + + public List getUserInfos() { + return userInfos; + } + + public void setUserInfos(List userInfos) { + this.userInfos = userInfos; + } + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSendMessageReq.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSendMessageReq.java new file mode 100644 index 00000000..4b7e2cc0 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoSendMessageReq.java @@ -0,0 +1,10 @@ +package cn.wildfirechat.pojos.mesh; + +import cn.wildfirechat.pojos.SendMessageData; + +public class PojoSendMessageReq { + public SendMessageData messageData; + public String clientId; + public String domainId; + public long messageId; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoString.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoString.java new file mode 100644 index 00000000..7a16d3a0 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoString.java @@ -0,0 +1,22 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoString { + public String domainId; + public String string; + + public String getString() { + return string; + } + + public void setString(String string) { + this.string = string; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoStringList.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoStringList.java new file mode 100644 index 00000000..e6bcfaf7 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoStringList.java @@ -0,0 +1,24 @@ +package cn.wildfirechat.pojos.mesh; + +import java.util.List; + +public class PojoStringList { + public String domainId; + public List stringList; + + public List getStringList() { + return stringList; + } + + public void setStringList(List stringList) { + this.stringList = stringList; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoTransferGroup.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoTransferGroup.java new file mode 100644 index 00000000..6653ea76 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoTransferGroup.java @@ -0,0 +1,40 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoTransferGroup { + public String domainId; + public String operator; + public String newOwner; + public String group_id; + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getGroup_id() { + return group_id; + } + + public void setGroup_id(String group_id) { + this.group_id = group_id; + } + + public String getNewOwner() { + return newOwner; + } + + public void setNewOwner(String newOwner) { + this.newOwner = newOwner; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceEvent.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceEvent.java new file mode 100644 index 00000000..0c510670 --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceEvent.java @@ -0,0 +1,9 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoUserConferenceEvent { + public String domainId; + public String data; + public String userId; + public String clientId; + public boolean isRobot; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceRequest.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceRequest.java new file mode 100644 index 00000000..08260a0c --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceRequest.java @@ -0,0 +1,12 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoUserConferenceRequest { + public String domainId; + public String clientID; + public String fromUser; + public String request; + public long sessionId; + public String roomId; + public String data; + public boolean advanced; +} diff --git a/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceResponse.java b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceResponse.java new file mode 100644 index 00000000..9b787cce --- /dev/null +++ b/common/src/main/java/cn/wildfirechat/pojos/mesh/PojoUserConferenceResponse.java @@ -0,0 +1,5 @@ +package cn.wildfirechat.pojos.mesh; + +public class PojoUserConferenceResponse { + public String data; +} diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java b/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java index 72469cf7..35d1205b 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java @@ -31,6 +31,11 @@ public class GroupAdmin { return AdminHttpUtils.httpJsonPost(path, input, PojoGroupInfo.class); } + public static IMResult batchGroupInfos(List groupIds) throws Exception { + String path = APIPath.Group_Batch_Info; + return AdminHttpUtils.httpJsonPost(path, groupIds, PojoGroupInfoList.class); + } + public static IMResult dismissGroup(String operator, String groupId, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Group_Dismiss; InputDismissGroup dismissGroup = new InputDismissGroup(); diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/MeshAdmin.java b/sdk/src/main/java/cn/wildfirechat/sdk/MeshAdmin.java new file mode 100644 index 00000000..6725856d --- /dev/null +++ b/sdk/src/main/java/cn/wildfirechat/sdk/MeshAdmin.java @@ -0,0 +1,229 @@ +package cn.wildfirechat.sdk; + +import cn.wildfirechat.common.APIPath; +import cn.wildfirechat.pojos.*; +import cn.wildfirechat.pojos.mesh.*; +import cn.wildfirechat.sdk.model.IMResult; +import cn.wildfirechat.sdk.utilities.AdminHttpUtils; + +import java.util.List; + +public class MeshAdmin { + public static IMResult createDomain(InputOutputDomainInfo domainInfo) throws Exception { + String path = APIPath.Create_Domain; + return AdminHttpUtils.httpJsonPost(path, domainInfo, Void.class); + } + + public static IMResult getDomain(String domainId) throws Exception { + String path = APIPath.Get_Domain; + InputStringValue inputId = new InputStringValue(); + inputId.setValue(domainId); + return AdminHttpUtils.httpJsonPost(path, inputId, InputOutputDomainInfo.class); + } + + public static IMResult deleteDomain(String domainId) throws Exception { + String path = APIPath.Destroy_Domain; + InputStringValue inputId = new InputStringValue(); + inputId.setValue(domainId); + return AdminHttpUtils.httpJsonPost(path, inputId, Void.class); + } + + public static IMResult getAllDomain() throws Exception { + String path = APIPath.List_Domain; + return AdminHttpUtils.httpJsonPost(path, null, InputOutputDomainInfoList.class); + } + + public static IMResult getBatchUserInfos(List userIds) throws Exception { + String path = APIPath.User_Batch_Get_Infos; + OutputStringList getUserInfo = new OutputStringList(userIds); + return AdminHttpUtils.httpJsonPost(path, getUserInfo, OutputUserInfoList.class); + } + + public static IMResult searchUser(String keyword, int searchType, int page) throws Exception { + String path = APIPath.Search_User; + PojoSearchUserReq req = new PojoSearchUserReq(); + req.keyword = keyword; + req.searchType = searchType; + req.page = page; + return AdminHttpUtils.httpJsonPost(path, req, PojoSearchUserRes.class); + } + + public static IMResult sendFriendRequest(String userId, String targetId, String reason) throws Exception { + String path = APIPath.Friend_Send_Request; + InputAddFriendRequest input = new InputAddFriendRequest(); + input.setUserId(userId); + input.setFriendUid(targetId); + input.setReason(reason); + input.setForce(false); + return AdminHttpUtils.httpJsonPost(path, input, Void.class); + } + + public static IMResult handleFriendRequest(String userId, String targetId, int status) throws Exception { + String path = APIPath.Handle_Friend_Send_Request; + InputHandleFriendRequest input = new InputHandleFriendRequest(); + input.setUserId(userId); + input.setFriendUid(targetId); + input.setStatus(status); + return AdminHttpUtils.httpJsonPost(path, input, Void.class); + } + + public static IMResult sendMessage(String sender, Conversation conversation, MessagePayload payload, List toUsers) throws Exception { + String path = APIPath.Msg_Send; + SendMessageData messageData = new SendMessageData(); + messageData.setSender(sender); + messageData.setConv(conversation); + messageData.setPayload(payload); + messageData.setToUsers(toUsers); + messageData.setMeshMessage(true); + if (payload.getType() == 1 && (payload.getSearchableContent() == null || payload.getSearchableContent().isEmpty())) { + System.out.println("Payload错误,Payload格式应该跟客户端消息encode出来的Payload对齐,这样客户端才能正确识别。比如文本消息,文本需要放到searchableContent属性。请与客户端同事确认Payload的格式,或则去 https://gitee.com/wfchat/android-chat/tree/master/client/src/main/java/cn/wildfirechat/message 找到消息encode的实现方法!"); + } + return AdminHttpUtils.httpJsonPost(path, messageData, SendMessageResult.class); + } + + public static IMResult publishMessage(SendMessageData messageData, List receivers) throws Exception { + String path = APIPath.Msg_Publish; + PojoPublishMessageReq req = new PojoPublishMessageReq(); + req.messageData = messageData; + req.receivers = receivers; + return AdminHttpUtils.httpJsonPost(path, req, SendMessageResult.class); + } + + public static IMResult recallMessage(String operator, long messageId) throws Exception { + String path = APIPath.Msg_Recall; + RecallMessageData req = new RecallMessageData(); + req.setOperator(operator); + req.setMessageUid(messageId); + req.setUserRecall(true); + return AdminHttpUtils.httpJsonPost(path, req, String.class); + } + + public static IMResult updateMessageContent(String operator, long messageUid, MessagePayload payload, boolean distribute) throws Exception { + String path = APIPath.Msg_Update; + UpdateMessageContentData updateMessageContentData = new UpdateMessageContentData(); + updateMessageContentData.setOperator(operator); + updateMessageContentData.setMessageUid(messageUid); + updateMessageContentData.setPayload(payload); + updateMessageContentData.setDistribute(distribute?1:0); + updateMessageContentData.setUpdateTimestamp(0); + updateMessageContentData.setMeshLocal(1); + return AdminHttpUtils.httpJsonPost(path, updateMessageContentData, Void.class); + } + + public static IMResult syncGroup(PojoGroupInfo group_info, List members) throws Exception { + String path = APIPath.Sync_Group; + PojoGroup pojoGroup = new PojoGroup(); + pojoGroup.setGroup_info(group_info); + pojoGroup.setMembers(members); + + return AdminHttpUtils.httpJsonPost(path, pojoGroup, Void.class); + } + + public static IMResult getGroupInfo(String groupId) throws Exception { + return GroupAdmin.getGroupInfo(groupId); + } + + public static IMResult getGroupMembers(String groupId) throws Exception { + return GroupAdmin.getGroupMembers(groupId); + } + + public static IMResult addGroupMembers(String operator, String groupId, List groupMembers, List to_lines, MessagePayload notify_message) throws Exception { + String path = APIPath.Group_Member_Add; + InputAddGroupMember addGroupMember = new InputAddGroupMember(); + addGroupMember.setGroup_id(groupId); + addGroupMember.setMembers(groupMembers); + addGroupMember.setOperator(operator); + addGroupMember.setTo_lines(to_lines); + addGroupMember.setNotify_message(notify_message); + addGroupMember.setMeshMessage(true); + return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class); + } + + public static IMResult batchGroupInfos(List groupIds) throws Exception { + return GroupAdmin.batchGroupInfos(groupIds); + } + + public static IMResult quitGroup(String operator, String groupId, List to_lines, MessagePayload notify_message) throws Exception { + String path = APIPath.Group_Member_Quit; + InputQuitGroup quitGroup = new InputQuitGroup(); + quitGroup.setGroup_id(groupId); + quitGroup.setOperator(operator); + quitGroup.setTo_lines(to_lines); + quitGroup.setNotify_message(notify_message); + quitGroup.setMeshMessage(true); + return AdminHttpUtils.httpJsonPost(path, quitGroup, Void.class); + } + + + public static IMResult dismissGroup(String operator, String groupId, List to_lines, MessagePayload notify_message) throws Exception { + String path = APIPath.Group_Dismiss; + InputDismissGroup dismissGroup = new InputDismissGroup(); + dismissGroup.setOperator(operator); + dismissGroup.setGroup_id(groupId); + dismissGroup.setTo_lines(to_lines); + dismissGroup.setNotify_message(notify_message); + dismissGroup.setMeshMessage(true); + return AdminHttpUtils.httpJsonPost(path, dismissGroup, Void.class); + } + + public static IMResult kickoffGroupMembers(String operator, String groupId, List groupMemberIds, List to_lines, MessagePayload notify_message) throws Exception { + String path = APIPath.Group_Member_Kickoff; + InputKickoffGroupMember kickoffGroupMember = new InputKickoffGroupMember(); + kickoffGroupMember.setGroup_id(groupId); + kickoffGroupMember.setMembers(groupMemberIds); + kickoffGroupMember.setOperator(operator); + kickoffGroupMember.setTo_lines(to_lines); + kickoffGroupMember.setMeshMessage(true); + kickoffGroupMember.setNotify_message(notify_message); + return AdminHttpUtils.httpJsonPost(path, kickoffGroupMember, Void.class); + } + + public static IMResult transferGroup(String operator, String groupId, String newOwner, List to_lines, MessagePayload notify_message) throws Exception { + String path = APIPath.Group_Transfer; + InputTransferGroup transferGroup = new InputTransferGroup(); + transferGroup.setGroup_id(groupId); + transferGroup.setNew_owner(newOwner); + transferGroup.setOperator(operator); + transferGroup.setTo_lines(to_lines); + transferGroup.setNotify_message(notify_message); + transferGroup.setMeshMessage(true); + return AdminHttpUtils.httpJsonPost(path, transferGroup, Void.class); + } + + public static IMResult modifyGroupInfo(String operator, String groupId, /*ModifyGroupInfoType*/int type, String value, List to_lines, MessagePayload notify_message) throws Exception { + String path = APIPath.Group_Modify_Info; + InputModifyGroupInfo modifyGroupInfo = new InputModifyGroupInfo(); + modifyGroupInfo.setGroup_id(groupId); + modifyGroupInfo.setOperator(operator); + modifyGroupInfo.setTo_lines(to_lines); + modifyGroupInfo.setType(type); + modifyGroupInfo.setValue(value); + modifyGroupInfo.setNotify_message(notify_message); + modifyGroupInfo.setMeshMessage(true); + return AdminHttpUtils.httpJsonPost(path, modifyGroupInfo, Void.class); + } + + public static IMResult userConferenceRequest(String clientID, String fromUser, String request, long sessionId, String roomId, String data, boolean advanced) throws Exception { + String path = APIPath.Conference_User_Request; + PojoUserConferenceRequest conferenceRequest = new PojoUserConferenceRequest(); + conferenceRequest.clientID = clientID; + conferenceRequest.fromUser = fromUser; + conferenceRequest.request = request; + conferenceRequest.sessionId = sessionId; + conferenceRequest.roomId = roomId; + conferenceRequest.data = data; + conferenceRequest.advanced = advanced; + return AdminHttpUtils.httpJsonPost(path, conferenceRequest, PojoUserConferenceResponse.class); + } + + public static IMResult userConferenceEvent(String data, String userId, String clientId, boolean isRobot) throws Exception { + String path = APIPath.Conference_User_Event; + PojoUserConferenceEvent event = new PojoUserConferenceEvent(); + event.data = data; + event.userId = userId; + event.clientId = clientId; + event.isRobot = isRobot; + return AdminHttpUtils.httpJsonPost(path, event, Void.class); + } + +} diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/JsonUtils.java b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/JsonUtils.java index de8b6fae..f7f71ae2 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/utilities/JsonUtils.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/utilities/JsonUtils.java @@ -1,5 +1,6 @@ package cn.wildfirechat.sdk.utilities; +import cn.wildfirechat.pojos.mesh.MeshRestResult; import cn.wildfirechat.sdk.model.IMResult; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -15,6 +16,22 @@ public class JsonUtils { return gson.fromJson(content, builder.build()); } + public static MeshRestResult fromJsonObject2(String content, Class clazz) { + TypeBuilder builder = TypeBuilder.newInstance(MeshRestResult.class); + if (!clazz.equals(Void.class)) { + builder.addTypeParam(clazz); + } + return gson.fromJson(content, builder.build()); + } + + public static T fromJsonObject3(String content, Class cls, Class clazz) { + TypeBuilder builder = TypeBuilder.newInstance(cls); + if (!clazz.equals(Void.class)) { + builder.addTypeParam(clazz); + } + return gson.fromJson(content, builder.build()); + } + public static boolean isNullOrEmpty(String str) { return str == null || str.isEmpty(); }