fix: Matrix改用HTTP API,修复HTTPS不可用问题,网页端消息同步到Matrix

This commit is contained in:
2026-04-11 12:56:00 +08:00
parent d3236413f3
commit 65297d7321
6 changed files with 149 additions and 95 deletions

View File

@@ -256,6 +256,10 @@ async def websocket_endpoint(websocket: WebSocket, user_id: str, db: Session = D
}
})
# 同步到Matrix如果有房间
if matrix_bot.is_running and matrix_bot.last_room_id:
await matrix_bot.send_message(matrix_bot.last_room_id, f"[网页] {message}")
# 获取对话历史
history = conv_service.get_conversation_history(conversation_id, limit=20)
@@ -284,6 +288,10 @@ async def websocket_endpoint(websocket: WebSocket, user_id: str, db: Session = D
}
})
# 同步AI回复到Matrix
if matrix_bot.is_running and matrix_bot.last_room_id:
await matrix_bot.send_message(matrix_bot.last_room_id, ai_response)
except Exception as e:
logger.error(f"AI调用失败: {e}")
await websocket.send_json({