1,添加获取用户机器人列表ID的接口。

2,机器人回调消息中添加回调的机器人ID。
3,mesh服务添加加群申请相关接口
This commit is contained in:
heavyrian2012
2026-02-02 13:48:04 +08:00
parent d08d6f0c49
commit 4d60231c8c
10 changed files with 126 additions and 0 deletions
@@ -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;
}
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) {
Connection connection = null;
PreparedStatement statement = null;
@@ -3249,6 +3249,11 @@ public class MemoryMessagesStore implements IMessagesStore {
return databaseStore.getAllUsers(count, offset);
}
@Override
public List<String> getUserRobotIds(String userId) {
return databaseStore.getUserRobotIds(userId);
}
// 电话号码校验正则表达式(支持中国大陆手机号和固话)
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);
List<WFCMessage.User> getUserInfoList(int count, int offset);
List<String> getUserRobotIds(String userId);
boolean updateSystemSetting(int id, String value, String desc);
SystemSettingPojo getSystemSetting(int id);
@@ -179,6 +179,7 @@ public class MessagesPublisher {
message = m_messagesStore.getMessage(messageId);
}
OutputMessageData outputMessageData = getOutputMessageWithExtraInfo(message, exceptClientId, m_messagesStore.isRobotCallbackWithClientInfo() , m_messagesStore.isRobotCallbackWithSenderInfo(), m_messagesStore.isRobotCallbackWithTargetInfo());
outputMessageData.setToRobotId(robot.getUid());
Server.getServer().getCallbackScheduler().execute(() -> {
try {
HttpUtils.httpJsonPost(robot.getCallback(), GsonUtil.gson.toJson(outputMessageData, OutputMessageData.class), HttpUtils.HttpPostType.POST_TYPE_Robot_Message_Callback);