mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-28 03:38:11 +08:00
Fix: add document delete permission check (#14472)
### What problem does this PR solve? add document delete permission check ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -1027,6 +1027,13 @@ async def delete_documents(tenant_id, dataset_id):
|
||||
if delete_all:
|
||||
doc_ids = [doc.id for doc in DocumentService.query(kb_id=dataset_id)]
|
||||
|
||||
dataset_doc_ids = {doc.id for doc in DocumentService.query(kb_id=dataset_id)}
|
||||
invalid_ids = [doc_id for doc_id in doc_ids if doc_id not in dataset_doc_ids]
|
||||
if invalid_ids:
|
||||
return get_error_data_result(
|
||||
message=f"These documents do not belong to dataset {dataset_id} or Document not found: {', '.join(invalid_ids)}"
|
||||
)
|
||||
|
||||
# make sure each id is unique
|
||||
unique_doc_ids, duplicate_messages = check_duplicate_ids(doc_ids, "document")
|
||||
if duplicate_messages:
|
||||
|
||||
Reference in New Issue
Block a user