Skip to content

Commit 93bab8d

Browse files
committed
refac
1 parent 259d5ca commit 93bab8d

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

backend/open_webui/routers/retrieval.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,17 +2592,15 @@ async def query_collection_handler(
25922592
)
25932593
elif collection_name.startswith("file-"):
25942594
file_id = collection_name[len("file-") :]
2595-
file = Files.get_file_by_id(file_id)
2596-
if file and file.user_id != user.id:
2597-
if not has_access_to_file(
2598-
file_id=file_id,
2599-
access_type="read",
2600-
user=user,
2601-
):
2602-
raise HTTPException(
2603-
status_code=status.HTTP_403_FORBIDDEN,
2604-
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
2605-
)
2595+
if not has_access_to_file(
2596+
file_id=file_id,
2597+
access_type="read",
2598+
user=user,
2599+
):
2600+
raise HTTPException(
2601+
status_code=status.HTTP_403_FORBIDDEN,
2602+
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
2603+
)
26062604

26072605
try:
26082606
if request.app.state.config.ENABLE_RAG_HYBRID_SEARCH and (

backend/open_webui/socket/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ async def __event_emitter__(event_data):
804804
Chats.add_message_status_to_chat_by_id_and_message_id,
805805
request_info["chat_id"],
806806
request_info["message_id"],
807-
status_data,
807+
event_data.get("data", {}),
808808
)
809809

810810
elif event_type == "message":

backend/open_webui/utils/access_control/files.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def has_access_to_file(
3232
if not file:
3333
return False
3434

35+
# Direct ownership
36+
if file.user_id == user.id:
37+
return True
38+
3539
# Check if the file is associated with any knowledge bases the user has access to
3640
knowledge_bases = Knowledges.get_knowledges_by_file_id(file_id, db=db)
3741
user_group_ids = {

0 commit comments

Comments
 (0)