File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1831,7 +1831,7 @@ async def query_knowledge_files(
18311831 elif item_type == "file" :
18321832 # Individual file - use file-{id} as collection name
18331833 file = Files .get_file_by_id (item_id )
1834- if file and ( user_role == "admin" or file . user_id == user_id ) :
1834+ if file :
18351835 collection_names .append (f"file-{ item_id } " )
18361836
18371837 elif item_type == "note" :
Original file line number Diff line number Diff line change 77from open_webui .models .channels import Channels
88from open_webui .models .chats import Chats
99from open_webui .models .groups import Groups
10+ from open_webui .models .models import Models
1011from open_webui .models .access_grants import AccessGrants
1112
1213log = logging .getLogger (__name__ )
@@ -21,6 +22,7 @@ def has_access_to_file(
2122 """
2223 Check if a user has the specified access to a file through any of:
2324 - Knowledge bases (ownership or access grants)
25+ - Shared workspace models that attach the file directly
2426 - Channels the user is a member of
2527 - Shared chats
2628
@@ -72,4 +74,12 @@ def has_access_to_file(
7274 if chats :
7375 return True
7476
77+ # Check if the file is directly attached to a shared workspace model
78+ for model in Models .get_models_by_user_id (user .id , permission = access_type , db = db ):
79+ knowledge_items = getattr (model .meta , "knowledge" , None ) or []
80+ for item in knowledge_items :
81+ if isinstance (item , dict ) and item .get ("type" ) == "file" and item .get ("id" ) == file .id :
82+ return True
83+
7584 return False
85+
You can’t perform that action at this time.
0 commit comments