1,添加获取用户机器人列表ID的接口。
2,机器人回调消息中添加回调的机器人ID。 3,mesh服务添加加群申请相关接口
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.xiaoleilu.loServer.action.admin;
|
||||||
|
|
||||||
|
import cn.wildfirechat.common.APIPath;
|
||||||
|
import cn.wildfirechat.common.ErrorCode;
|
||||||
|
import cn.wildfirechat.pojos.InputRobotId;
|
||||||
|
import cn.wildfirechat.pojos.InputUserId;
|
||||||
|
import cn.wildfirechat.pojos.OutputRobot;
|
||||||
|
import cn.wildfirechat.pojos.OutputStringList;
|
||||||
|
import cn.wildfirechat.proto.WFCMessage;
|
||||||
|
import com.xiaoleilu.loServer.RestResult;
|
||||||
|
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||||
|
import com.xiaoleilu.loServer.annotation.Route;
|
||||||
|
import com.xiaoleilu.loServer.handler.Request;
|
||||||
|
import com.xiaoleilu.loServer.handler.Response;
|
||||||
|
import io.netty.handler.codec.http.FullHttpRequest;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
|
|
||||||
|
@Route(APIPath.User_Get_User_Robots)
|
||||||
|
@HttpMethod("POST")
|
||||||
|
public class GetUserRobotsAction extends AdminAction {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTransactionAction() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean action(Request request, Response response) {
|
||||||
|
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||||
|
InputUserId inputUserId = getRequestBody(request.getNettyRequest(), InputUserId.class);
|
||||||
|
if (inputUserId != null
|
||||||
|
&& (!StringUtil.isNullOrEmpty(inputUserId.getUserId()))) {
|
||||||
|
RestResult result = RestResult.ok(new OutputStringList(messagesStore.getUserRobotIds(inputUserId.getUserId())));
|
||||||
|
setResponseContent(result, response);
|
||||||
|
} else {
|
||||||
|
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3177,6 +3177,34 @@ public class DatabaseStore {
|
|||||||
return outList;
|
return outList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> getUserRobotIds(String userId) {
|
||||||
|
Connection connection = null;
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
List<String> outList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
connection = DBUtil.getConnection();
|
||||||
|
String sql = "select _uid from t_robot where _owner = ? and _state = 0";
|
||||||
|
statement = connection.prepareStatement(sql);
|
||||||
|
|
||||||
|
int index = 1;
|
||||||
|
statement.setString(1, userId);
|
||||||
|
|
||||||
|
rs = statement.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
outList.add(rs.getString(1));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e, RDBS_Exception);
|
||||||
|
} finally {
|
||||||
|
DBUtil.closeDB(connection, statement, rs);
|
||||||
|
}
|
||||||
|
return outList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Set<String> getAllEnds(boolean fromUserTable) {
|
Set<String> getAllEnds(boolean fromUserTable) {
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
|||||||
@@ -3249,6 +3249,11 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
return databaseStore.getAllUsers(count, offset);
|
return databaseStore.getAllUsers(count, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getUserRobotIds(String userId) {
|
||||||
|
return databaseStore.getUserRobotIds(userId);
|
||||||
|
}
|
||||||
|
|
||||||
// 电话号码校验正则表达式(支持中国大陆手机号和固话)
|
// 电话号码校验正则表达式(支持中国大陆手机号和固话)
|
||||||
private static final String PHONE_REGEX = "^\\s*" + // 允许开头空白
|
private static final String PHONE_REGEX = "^\\s*" + // 允许开头空白
|
||||||
"(?:" +
|
"(?:" +
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ public interface IMessagesStore {
|
|||||||
ErrorCode searchUser(String userId, String keyword, int searchType, int userType, int page, List<WFCMessage.User> users);
|
ErrorCode searchUser(String userId, String keyword, int searchType, int userType, int page, List<WFCMessage.User> users);
|
||||||
|
|
||||||
List<WFCMessage.User> getUserInfoList(int count, int offset);
|
List<WFCMessage.User> getUserInfoList(int count, int offset);
|
||||||
|
List<String> getUserRobotIds(String userId);
|
||||||
|
|
||||||
boolean updateSystemSetting(int id, String value, String desc);
|
boolean updateSystemSetting(int id, String value, String desc);
|
||||||
SystemSettingPojo getSystemSetting(int id);
|
SystemSettingPojo getSystemSetting(int id);
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ public class MessagesPublisher {
|
|||||||
message = m_messagesStore.getMessage(messageId);
|
message = m_messagesStore.getMessage(messageId);
|
||||||
}
|
}
|
||||||
OutputMessageData outputMessageData = getOutputMessageWithExtraInfo(message, exceptClientId, m_messagesStore.isRobotCallbackWithClientInfo() , m_messagesStore.isRobotCallbackWithSenderInfo(), m_messagesStore.isRobotCallbackWithTargetInfo());
|
OutputMessageData outputMessageData = getOutputMessageWithExtraInfo(message, exceptClientId, m_messagesStore.isRobotCallbackWithClientInfo() , m_messagesStore.isRobotCallbackWithSenderInfo(), m_messagesStore.isRobotCallbackWithTargetInfo());
|
||||||
|
outputMessageData.setToRobotId(robot.getUid());
|
||||||
Server.getServer().getCallbackScheduler().execute(() -> {
|
Server.getServer().getCallbackScheduler().execute(() -> {
|
||||||
try {
|
try {
|
||||||
HttpUtils.httpJsonPost(robot.getCallback(), GsonUtil.gson.toJson(outputMessageData, OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Robot_Message_Callback);
|
HttpUtils.httpJsonPost(robot.getCallback(), GsonUtil.gson.toJson(outputMessageData, OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Robot_Message_Callback);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public interface APIPath {
|
|||||||
String User_Get_Email_Info = "/admin/user/get_info_by_email";
|
String User_Get_Email_Info = "/admin/user/get_info_by_email";
|
||||||
String User_Get_All = "/admin/user/all";
|
String User_Get_All = "/admin/user/all";
|
||||||
String User_Get_Robot_Info = "/admin/user/get_robot_info";
|
String User_Get_Robot_Info = "/admin/user/get_robot_info";
|
||||||
|
String User_Get_User_Robots = "/admin/user/get_user_robots";
|
||||||
String User_Get_Blocked_List = "/admin/user/get_blocked_list";
|
String User_Get_Blocked_List = "/admin/user/get_blocked_list";
|
||||||
String User_Check_Block_Status = "/admin/user/check_block_status";
|
String User_Check_Block_Status = "/admin/user/check_block_status";
|
||||||
String User_Get_Online_Status = "/admin/user/onlinestatus";
|
String User_Get_Online_Status = "/admin/user/onlinestatus";
|
||||||
@@ -95,6 +96,7 @@ public interface APIPath {
|
|||||||
String Group_Set_Manager = "/admin/group/manager/set";
|
String Group_Set_Manager = "/admin/group/manager/set";
|
||||||
String Group_Mute_Member = "/admin/group/manager/mute";
|
String Group_Mute_Member = "/admin/group/manager/mute";
|
||||||
String Group_Allow_Member = "/admin/group/manager/allow";
|
String Group_Allow_Member = "/admin/group/manager/allow";
|
||||||
|
String Group_Join_Request_Add = "/admin/group/join_request/add";
|
||||||
String Get_User_Groups = "/admin/group/of_user";
|
String Get_User_Groups = "/admin/group/of_user";
|
||||||
String Get_User_Groups_By_Type = "/admin/group/of_user_by_type";
|
String Get_User_Groups_By_Type = "/admin/group/of_user_by_type";
|
||||||
String Group_Set_Member_Alias = "/admin/group/member/set_alias";
|
String Group_Set_Member_Alias = "/admin/group/member/set_alias";
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public class OutputMessageData {
|
|||||||
private PojoGroupInfo targetGroupInfo;
|
private PojoGroupInfo targetGroupInfo;
|
||||||
private OutputGetChannelInfo targetChannelInfo;
|
private OutputGetChannelInfo targetChannelInfo;
|
||||||
|
|
||||||
|
private String toRobotId;
|
||||||
|
|
||||||
public String getSender() {
|
public String getSender() {
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
@@ -119,6 +121,14 @@ public class OutputMessageData {
|
|||||||
return fromProtoMessage(protoMessage, null);
|
return fromProtoMessage(protoMessage, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getToRobotId() {
|
||||||
|
return toRobotId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToRobotId(String toRobotId) {
|
||||||
|
this.toRobotId = toRobotId;
|
||||||
|
}
|
||||||
|
|
||||||
public static OutputMessageData fromProtoMessage(WFCMessage.Message protoMessage, OutputClient fromClient) {
|
public static OutputMessageData fromProtoMessage(WFCMessage.Message protoMessage, OutputClient fromClient) {
|
||||||
OutputMessageData data = new OutputMessageData();
|
OutputMessageData data = new OutputMessageData();
|
||||||
data.messageId = protoMessage.getMessageId();
|
data.messageId = protoMessage.getMessageId();
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package cn.wildfirechat.pojos.mesh;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PojoAddJoinGroupRequest {
|
||||||
|
public String domainId;
|
||||||
|
public String operator;
|
||||||
|
public String group_id;
|
||||||
|
public List<String> userIds;
|
||||||
|
public String reason;
|
||||||
|
public String extra;
|
||||||
|
}
|
||||||
@@ -141,6 +141,17 @@ public class MeshAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IMResult<Void> addJoinGroupRequest(String operator, String groupId, List<String> userIds, String reason, String extra) throws Exception {
|
||||||
|
String path = APIPath.Group_Join_Request_Add;
|
||||||
|
PojoAddJoinGroupRequest addGroupMember = new PojoAddJoinGroupRequest();
|
||||||
|
addGroupMember.operator = operator;
|
||||||
|
addGroupMember.group_id = groupId;
|
||||||
|
addGroupMember.userIds = userIds;
|
||||||
|
addGroupMember.reason = reason;
|
||||||
|
addGroupMember.extra = extra;
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class);
|
||||||
|
}
|
||||||
|
|
||||||
public static IMResult<PojoGroupInfoList> batchGroupInfos(List<String> groupIds) throws Exception {
|
public static IMResult<PojoGroupInfoList> batchGroupInfos(List<String> groupIds) throws Exception {
|
||||||
return GroupAdmin.batchGroupInfos(groupIds);
|
return GroupAdmin.batchGroupInfos(groupIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,13 @@ public class UserAdmin {
|
|||||||
return AdminHttpUtils.httpJsonPost(path, getRobotInfo, OutputRobot.class);
|
return AdminHttpUtils.httpJsonPost(path, getRobotInfo, OutputRobot.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IMResult<OutputStringList> getUserRobots(String userId) throws Exception {
|
||||||
|
String path = APIPath.User_Get_User_Robots;
|
||||||
|
InputUserId getRobotInfo = new InputUserId();
|
||||||
|
getRobotInfo.setUserId(userId);
|
||||||
|
return AdminHttpUtils.httpJsonPost(path, getRobotInfo, OutputStringList.class);
|
||||||
|
}
|
||||||
|
|
||||||
public static IMResult<OutputGetIMTokenData> getUserToken(String userId, String clientId, int platform) throws Exception {
|
public static IMResult<OutputGetIMTokenData> getUserToken(String userId, String clientId, int platform) throws Exception {
|
||||||
String path = APIPath.User_Get_Token;
|
String path = APIPath.User_Get_Token;
|
||||||
InputGetToken getToken = new InputGetToken(userId, clientId, platform);
|
InputGetToken getToken = new InputGetToken(userId, clientId, platform);
|
||||||
|
|||||||
Reference in New Issue
Block a user