Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3624: fix manager permission within groups #3754

Merged
merged 13 commits into from
Mar 17, 2024
Prev Previous commit
Next Next commit
Query returns UUID only
matlink committed Feb 17, 2024
commit f4e9857dfd73f80f3151649250fd360c4f0a9e80
18 changes: 5 additions & 13 deletions src/db/models/group.rs
Original file line number Diff line number Diff line change
@@ -488,27 +488,19 @@ impl GroupUser {
}}
}

pub async fn find_by_collection(collection_uuid: &str, conn: &mut DbConn) -> Vec<Self> {
pub async fn get_collection_group_users_uuid(collection_uuid: &str, conn: &mut DbConn) -> HashSet<String> {
db_run! { conn: {
groups_users::table
.inner_join(collections_groups::table.on(
collections_groups::groups_uuid.eq(groups_users::groups_uuid)
))
.filter(collections_groups::collections_uuid.eq(collection_uuid))
.select(groups_users::all_columns)
.load::<GroupUserDb>(conn)
.select(groups_users::users_organizations_uuid)
.load::<String>(conn)
.expect("Error loading group users for collection")
.from_db()
}}
}

/// returns uuid of members of collection groups
pub async fn get_collection_group_users_uuid(collection_uuid: &str, conn: &mut DbConn) -> HashSet<String> {
GroupUser::find_by_collection(collection_uuid, conn)
.await
.iter()
.map(|u| u.users_organizations_uuid.clone())
.collect()
.into_iter()
.collect()
}

pub async fn update_user_revision(&self, conn: &mut DbConn) {