RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix: team doc deletion issue. (#6589)
Kevin Huecc9605a32ea
diff --git a/api/db/services/document_service.py b/api/db/services/document_service.pyindex 81203f0869..5295b38e33 100644--- a/api/db/services/document_service.py+++ b/api/db/services/document_service.py@@ -27,7 +27,7 @@ import xxhashfrom peewee import fnfrom api import settings-from api.db import FileType, LLMType, ParserType, StatusEnum, TaskStatus+from api.db import FileType, LLMType, ParserType, StatusEnum, TaskStatus, UserTenantRolefrom api.db.db_models import DB, Document, Knowledgebase, Task, Tenant, UserTenantfrom api.db.db_utils import bulk_insert_into_dbfrom api.db.services.common_service import CommonService@@ -262,11 +262,18 @@ class DocumentService(CommonService):@classmethod@DB.connection_context()def accessible4deletion(cls, doc_id, user_id):- docs = cls.model.select(- cls.model.id).join(+ docs = cls.model.select(cls.model.id+ ).join(Knowledgebase, on=(Knowledgebase.id == cls.model.kb_id)- ).where(cls.model.id == doc_id, Knowledgebase.created_by == user_id).paginate(0, 1)+ ).join(+ UserTenant, on=(+ (UserTenant.tenant_id == Knowledgebase.created_by) & (UserTenant.user_id == user_id))+ ).where(+ cls.model.id == doc_id,+ UserTenant.status == StatusEnum.VALID.value,+ ((UserTenant.role == UserTenantRole.NORMAL) | (UserTenant.role == UserTenantRole.OWNER))+ ).paginate(0, 1)docs = docs.dicts()if not docs:return False