Browse Source
Save members when updating groups
The web client uses this API endpoint to add users to groups.
pull/3285/head
David Christofas
2 years ago
No known key found for this signature in database
GPG Key ID: 3DC01E0F7E7BD83E
1 changed files with
18 additions and
0 deletions
-
src/api/core/organizations.rs
|
|
@ -2078,6 +2078,7 @@ struct GroupRequest { |
|
|
|
AccessAll: Option<bool>, |
|
|
|
ExternalId: Option<String>, |
|
|
|
Collections: Vec<SelectionReadOnly>, |
|
|
|
Users: Vec<String>, |
|
|
|
} |
|
|
|
|
|
|
|
impl GroupRequest { |
|
|
@ -2204,6 +2205,23 @@ async fn put_group( |
|
|
|
let updated_group = group_request.update_group(group)?; |
|
|
|
|
|
|
|
CollectionGroup::delete_all_by_group(&group_id, &mut conn).await?; |
|
|
|
GroupUser::delete_all_by_group(&group_id, &mut conn).await?; |
|
|
|
|
|
|
|
for assigned_user_id in group_request.Users { |
|
|
|
let mut user_entry = GroupUser::new(group_id.clone(), assigned_user_id.clone()); |
|
|
|
user_entry.save(&mut conn).await?; |
|
|
|
|
|
|
|
log_event( |
|
|
|
EventType::OrganizationUserUpdatedGroups as i32, |
|
|
|
&assigned_user_id, |
|
|
|
org_id.clone(), |
|
|
|
headers.user.uuid.clone(), |
|
|
|
headers.device.atype, |
|
|
|
&ip.ip, |
|
|
|
&mut conn, |
|
|
|
) |
|
|
|
.await; |
|
|
|
} |
|
|
|
|
|
|
|
log_event( |
|
|
|
EventType::GroupUpdated as i32, |
|
|
|