From 226d0ff77c47799669402ba5026b5bc32dff3dac Mon Sep 17 00:00:00 2001 From: Haruko386 Date: Fri, 3 Jul 2026 18:25:31 +0800 Subject: [PATCH] fix: get team merber's chat (#16597) ### Summary As title --- internal/service/chat.go | 41 +++++++++------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/internal/service/chat.go b/internal/service/chat.go index ff6c4568e1..85aaace71a 100644 --- a/internal/service/chat.go +++ b/internal/service/chat.go @@ -76,42 +76,19 @@ type ListChatsResponse struct { // ListChats list chats for a user func (s *ChatService) ListChats(userID, status, keywords string, page, pageSize int, orderby string, desc bool) (*ListChatsResponse, error) { - // Get tenant IDs by user ID - tenantIDs, err := s.userTenantDAO.GetTenantIDsByUserID(userID) + chats, total, err := s.chatDAO.ListByTenantIDs( + nil, + userID, + page, + pageSize, + orderby, + desc, + keywords, + ) if err != nil { return nil, err } - // For now, use the first tenant ID (primary tenant) - // This matches the Python implementation behavior - var tenantID string - if len(tenantIDs) > 0 { - tenantID = tenantIDs[0] - } else { - tenantID = userID - } - - // Query chats by tenant ID - chats, err := s.chatDAO.ListByTenantID(tenantID, status) - if err != nil { - return nil, err - } - - total := int64(len(chats)) - - if page > 0 && pageSize > 0 { - start := (page - 1) * pageSize - end := start + pageSize - if start < int(total) { - if end > int(total) { - end = int(total) - } - chats = chats[start:end] - } else { - chats = []*entity.Chat{} - } - } - // Enrich with knowledge base names chatsWithKBNames := make([]*ChatWithKBNames, 0, len(chats)) for _, chat := range chats {