添加Mesh相关SDK

This commit is contained in:
heavyrian2012
2024-06-21 16:45:10 +08:00
parent 68ae7dbd58
commit d751a7080b
38 changed files with 1172 additions and 0 deletions
+13
View File
@@ -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;
+16
View File
@@ -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;
@@ -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";
@@ -15,6 +15,7 @@ public class InputGroupBase {
public String operator;
public List<Integer> 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;
}
}
@@ -0,0 +1,50 @@
/*
* 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 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;
}
}
@@ -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;
}
}
@@ -0,0 +1,85 @@
/*
* 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 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;
}
}
@@ -0,0 +1,24 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
import java.util.List;
public class InputOutputDomainInfoList {
public List<InputOutputDomainInfo> infos;
public List<InputOutputDomainInfo> getInfos() {
return infos;
}
public void setInfos(List<InputOutputDomainInfo> infos) {
this.infos = infos;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -0,0 +1,23 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.pojos;
import java.util.List;
public class PojoGroupInfoList {
public List<PojoGroupInfo> groupInfoList;
public List<PojoGroupInfo> getGroupInfoList() {
return groupInfoList;
}
public void setGroupInfoList(List<PojoGroupInfo> groupInfoList) {
this.groupInfoList = groupInfoList;
}
}
@@ -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;
}
@@ -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;
}
}
@@ -19,6 +19,7 @@ public class SendMessageData {
private Conversation conv;
private MessagePayload payload;
private List<String> 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 ||
@@ -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;
}
}
@@ -0,0 +1,139 @@
package cn.wildfirechat.pojos.mesh;
import com.google.gson.Gson;
public class MeshRestResult<T> {
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;
}
}
@@ -0,0 +1,8 @@
package cn.wildfirechat.pojos.mesh;
public class PojoAddFriendReq {
public String fromUserId;
public String reason;
public String targetUserId;
public String domainId;
}
@@ -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<PojoGroupMember> 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<PojoGroupMember> getMembers() {
return members;
}
public void setMembers(List<PojoGroupMember> members) {
this.members = members;
}
public String getDomainId() {
return domainId;
}
public void setDomainId(String domainId) {
this.domainId = domainId;
}
}
@@ -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;
}
}
@@ -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<String> domainIds;
public PojoGroupInfo groupInfo;
public List<PojoGroupMember> members;
public List<String> getDomainIds() {
return domainIds;
}
public void setDomainIds(List<String> domainIds) {
this.domainIds = domainIds;
}
public PojoGroupInfo getGroupInfo() {
return groupInfo;
}
public void setGroupInfo(PojoGroupInfo groupInfo) {
this.groupInfo = groupInfo;
}
public List<PojoGroupMember> getMembers() {
return members;
}
public void setMembers(List<PojoGroupMember> members) {
this.members = members;
}
}
@@ -0,0 +1,8 @@
package cn.wildfirechat.pojos.mesh;
public class PojoHandleFriendRequestReq {
public String userId;
public int status;
public String targetUserId;
public String domainId;
}
@@ -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<String> 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<String> getMembers() {
return members;
}
public void setMembers(List<String> members) {
this.members = members;
}
}
@@ -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;
}
}
@@ -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<String> receivers;
public String domainId;
public long messageId;
public boolean republish;
}
@@ -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;
}
}
@@ -0,0 +1,8 @@
package cn.wildfirechat.pojos.mesh;
public class PojoRecallMessageReq {
public String domainId;
public long messageId;
public String operator;
public boolean isSenderRecall;
}
@@ -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;
}
}
@@ -0,0 +1,26 @@
package cn.wildfirechat.pojos.mesh;
import cn.wildfirechat.pojos.InputOutputUserInfo;
import java.util.List;
public class PojoSearchUserRes {
public List<InputOutputUserInfo> userInfos;
public String keyword;
public List<InputOutputUserInfo> getUserInfos() {
return userInfos;
}
public void setUserInfos(List<InputOutputUserInfo> userInfos) {
this.userInfos = userInfos;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
}
@@ -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;
}
@@ -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;
}
}
@@ -0,0 +1,24 @@
package cn.wildfirechat.pojos.mesh;
import java.util.List;
public class PojoStringList {
public String domainId;
public List<String> stringList;
public List<String> getStringList() {
return stringList;
}
public void setStringList(List<String> stringList) {
this.stringList = stringList;
}
public String getDomainId() {
return domainId;
}
public void setDomainId(String domainId) {
this.domainId = domainId;
}
}
@@ -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;
}
}
@@ -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;
}
@@ -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;
}
@@ -0,0 +1,5 @@
package cn.wildfirechat.pojos.mesh;
public class PojoUserConferenceResponse {
public String data;
}
@@ -31,6 +31,11 @@ public class GroupAdmin {
return AdminHttpUtils.httpJsonPost(path, input, PojoGroupInfo.class);
}
public static IMResult<PojoGroupInfoList> batchGroupInfos(List<String> groupIds) throws Exception {
String path = APIPath.Group_Batch_Info;
return AdminHttpUtils.httpJsonPost(path, groupIds, PojoGroupInfoList.class);
}
public static IMResult<Void> dismissGroup(String operator, String groupId, List<Integer> to_lines, MessagePayload notify_message) throws Exception {
String path = APIPath.Group_Dismiss;
InputDismissGroup dismissGroup = new InputDismissGroup();
@@ -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<Void> createDomain(InputOutputDomainInfo domainInfo) throws Exception {
String path = APIPath.Create_Domain;
return AdminHttpUtils.httpJsonPost(path, domainInfo, Void.class);
}
public static IMResult<InputOutputDomainInfo> 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<Void> 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<InputOutputDomainInfoList> getAllDomain() throws Exception {
String path = APIPath.List_Domain;
return AdminHttpUtils.httpJsonPost(path, null, InputOutputDomainInfoList.class);
}
public static IMResult<OutputUserInfoList> getBatchUserInfos(List<String> 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<PojoSearchUserRes> 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<Void> 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<Void> 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<SendMessageResult> sendMessage(String sender, Conversation conversation, MessagePayload payload, List<String> 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<SendMessageResult> publishMessage(SendMessageData messageData, List<String> 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<String> 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<Void> 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<Void> syncGroup(PojoGroupInfo group_info, List<PojoGroupMember> 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<PojoGroupInfo> getGroupInfo(String groupId) throws Exception {
return GroupAdmin.getGroupInfo(groupId);
}
public static IMResult<OutputGroupMemberList> getGroupMembers(String groupId) throws Exception {
return GroupAdmin.getGroupMembers(groupId);
}
public static IMResult<Void> addGroupMembers(String operator, String groupId, List<PojoGroupMember> groupMembers, List<Integer> 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<PojoGroupInfoList> batchGroupInfos(List<String> groupIds) throws Exception {
return GroupAdmin.batchGroupInfos(groupIds);
}
public static IMResult<Void> quitGroup(String operator, String groupId, List<Integer> 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<Void> dismissGroup(String operator, String groupId, List<Integer> 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<Void> kickoffGroupMembers(String operator, String groupId, List<String> groupMemberIds, List<Integer> 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<Void> transferGroup(String operator, String groupId, String newOwner, List<Integer> 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<Void> modifyGroupInfo(String operator, String groupId, /*ModifyGroupInfoType*/int type, String value, List<Integer> 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<PojoUserConferenceResponse> 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<Void> 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);
}
}
@@ -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 <T> MeshRestResult<T> fromJsonObject2(String content, Class<T> clazz) {
TypeBuilder builder = TypeBuilder.newInstance(MeshRestResult.class);
if (!clazz.equals(Void.class)) {
builder.addTypeParam(clazz);
}
return gson.fromJson(content, builder.build());
}
public static <T, K> T fromJsonObject3(String content, Class<T> cls, Class<K> 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();
}