```
feat(feishu): 添加飞书长连接支持并重构事件处理 添加了 FeishuEventService 来统一处理飞书消息事件, 新增 long_connection.py 实现长连接客户端, 修改 webhook 路由使用新的事件处理服务, 添加了 lark-oapi 依赖支持长连接功能, 更新测试用例覆盖新的事件处理逻辑。 BREAKING CHANGE: 飞书事件处理逻辑重构,统一使用 FeishuEventService 进行消息处理和审计记录。 ```
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
@@ -7,6 +8,8 @@ _db.close()
|
||||
|
||||
os.environ["DATABASE_URL"] = "sqlite:///" + _db.name.replace("\\", "/")
|
||||
os.environ["API_KEY"] = "test-key"
|
||||
os.environ["FEISHU_APP_ID"] = ""
|
||||
os.environ["FEISHU_APP_SECRET"] = ""
|
||||
os.environ["MODEL_PROVIDER"] = "noop"
|
||||
os.environ["SCHEDULER_ENABLED"] = "false"
|
||||
|
||||
@@ -60,6 +63,26 @@ def test_project_report_and_feishu_command_preview() -> None:
|
||||
assert response.json()["command"] == "daily_brief"
|
||||
|
||||
|
||||
def test_feishu_webhook_routes_message_event() -> None:
|
||||
payload = {
|
||||
"schema": "2.0",
|
||||
"header": {"event_type": "im.message.receive_v1"},
|
||||
"event": {
|
||||
"sender": {"sender_id": {"open_id": "ou_test"}},
|
||||
"message": {
|
||||
"chat_id": "oc_test",
|
||||
"message_type": "text",
|
||||
"content": json.dumps({"text": "risk"}),
|
||||
},
|
||||
},
|
||||
}
|
||||
response = client.post("/api/v1/integrations/feishu/webhook", json=payload)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["handled"] is True
|
||||
assert data["result"]["command"] == "risk_summary"
|
||||
|
||||
|
||||
def test_approval_gate_for_high_risk_update() -> None:
|
||||
create_response = client.post(
|
||||
"/api/v1/business/fund-accounts",
|
||||
|
||||
Reference in New Issue
Block a user