From f41290184a8aac0089fdc1769b4258bcbc5d4eae Mon Sep 17 00:00:00 2001 From: Stefan Melmuk Date: Sat, 6 Jan 2024 06:17:42 +0100 Subject: [PATCH] fix get_org_collection_detail too --- src/api/core/organizations.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index 639eeb625cc..0cb25995a5e 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -669,24 +669,23 @@ async fn get_org_collection_detail( Vec::with_capacity(0) }; - let mut assigned = false; let users: Vec = CollectionUser::find_by_collection_swap_user_uuid_with_org_user_uuid(&collection.uuid, &mut conn) .await .iter() .map(|collection_user| { - // Remember `user_uuid` is swapped here with the `user_org.uuid` with a join during the `find_by_collection_swap_user_uuid_with_org_user_uuid` call. - // We check here if the current user is assigned to this collection or not. - if collection_user.user_uuid == user_org.uuid { - assigned = true; - } SelectionReadOnly::to_collection_user_details_read_only(collection_user).to_json() }) .collect(); - if user_org.access_all { - assigned = true; - } + let assigned = user_org.access_all + || CollectionUser::find_by_collection_and_user(&collection.uuid, &user_org.user_uuid, &mut conn) + .await + .is_some() + || (CONFIG.org_groups_enabled() + && (GroupUser::has_full_access_by_member(org_id, &user_org.uuid, &mut conn).await + || GroupUser::has_access_to_collection_by_member(&collection.uuid, &user_org.uuid, &mut conn) + .await)); let mut json_object = collection.to_json(); json_object["Assigned"] = json!(assigned);