Skip to content

Commit

Permalink
fix get_org_collection_detail too
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan0xC committed Jan 6, 2024
1 parent 94129f9 commit f412901
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/api/core/organizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,24 +669,23 @@ async fn get_org_collection_detail(
Vec::with_capacity(0)
};

let mut assigned = false;
let users: Vec<Value> =
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);
Expand Down

0 comments on commit f412901

Please sign in to comment.