fix: get team merber's chat (#16597)

### Summary

As title
This commit is contained in:
Haruko386
2026-07-03 18:25:31 +08:00
committed by GitHub
parent 488574fd80
commit 226d0ff77c

View File

@@ -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 {