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:
@@ -128,21 +128,22 @@ async def export_chat_html(
|
||||
start: Annotated[int | None, Query(ge=0)] = None,
|
||||
end: Annotated[int | None, Query(ge=0)] = None,
|
||||
) -> Response:
|
||||
q = (
|
||||
sa.select(Message)
|
||||
.where(Message.channel == channel)
|
||||
.where(Message.owner_account_id == owner_account_id)
|
||||
)
|
||||
# 群聊(room_id)不按 owner 过滤:chat_group 表按 room 去重、owner 被末位
|
||||
# 员工覆盖,与消息实际归属 owner 错位会导出空文件(同 ChatTimeline 修复,
|
||||
# 2026-08-22);room 全局唯一且消息只在单一 owner 名下。
|
||||
q = sa.select(Message).where(Message.channel == channel)
|
||||
peer = ""
|
||||
if room_id:
|
||||
q = q.where(Message.room_id == room_id)
|
||||
peer = room_id
|
||||
elif talker_id:
|
||||
# DM:限定 room_id 为空,避免误捞群消息
|
||||
q = q.where(Message.talker_id == talker_id).where(
|
||||
(Message.room_id == None) | (Message.room_id == "") # noqa: E711
|
||||
)
|
||||
peer = talker_id
|
||||
else:
|
||||
q = q.where(Message.owner_account_id == owner_account_id)
|
||||
if talker_id:
|
||||
# DM:限定 room_id 为空,避免误捞群消息
|
||||
q = q.where(Message.talker_id == talker_id).where(
|
||||
(Message.room_id == None) | (Message.room_id == "") # noqa: E711
|
||||
)
|
||||
peer = talker_id
|
||||
if start is not None:
|
||||
q = q.where(Message.timestamp >= start)
|
||||
if end is not None:
|
||||
|
||||
Reference in New Issue
Block a user