fix(export+calls): 同类owner错位问题全面修复(群导出不按owner过滤+群语音客户点击走群聊路由)

- /api/export/chat-html: room 查询忽略 owner(chat_group owner 错位同
  ChatTimeline,群列表/聊天页的导出按钮原来会导出空文件)
- CallList viewCallCustomer: talker 以 @chatroom 结尾→group-chat 路由
  (原走 1:1 路由按 talker_id 查@chatroom 恒空)
- TDD: 群消息在 ownerB 名下用 ownerA+room 导出仍能拿到;428 测试绿
- 实测:错位 owner 导出 43304 群返回 15002 个消息元素

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-22 17:00:43 +08:00
parent 4f375c3d71
commit a8b8d9d81c
3 changed files with 51 additions and 12 deletions
+23
View File
@@ -137,3 +137,26 @@ async def test_export_no_warning_below_cap(make_client):
assert r.status_code == 200
# No warning DIV (the CSS class still lives in <style> — that's fine).
assert '<div class="export-warning">' not in r.text
# ---------------------------------------------------------------------------
# 群导出 owner 错位修复(2026-08-22): room 查询不带 owner
# ---------------------------------------------------------------------------
async def test_export_group_ignores_owner_mismatch(make_client):
"""群消息在 owner B 名下,用 owner A + room 导出仍能拿到(不按 owner 过滤)。"""
from app.db.models import Customer as _C # noqa: F401 (对齐既有 seed 风格)
async def seed(session):
session.add_all([
Message(msg_id="gm1", channel="wechat", owner_account_id="ownerB", talker_id=None, room_id="gX@chatroom", text="群消息1", timestamp=100),
Message(msg_id="gm2", channel="wechat", owner_account_id="ownerB", talker_id=None, room_id="gX@chatroom", text="群消息2", timestamp=200),
])
await session.commit()
client = await make_client(seed)
r = await client.get("/api/export/chat-html", params={
"channel": "wechat", "owner_account_id": "ownerA", "room_id": "gX@chatroom"})
assert r.status_code == 200
assert "群消息1" in r.text
assert "群消息2" in r.text