Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

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

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