check for pending users
@@ -1579,6 +1579,7 @@ pub async fn sync_users(
// Initialize the Zoom client.
let mut zoom_users: HashMap<String, zoom_api::types::UsersResponse> = HashMap::new();
+ let mut zoom_users_pending: HashMap<String, zoom_api::types::UsersResponse> = HashMap::new();
let zoom_auth = company.authenticate_zoom(db).await;
if let Some(ref zoom) = zoom_auth {
let active_users = zoom
@@ -1593,6 +1594,20 @@ pub async fn sync_users(
for r in active_users {
zoom_users.insert(r.email.to_string(), r);
}
+
+ // Get the pending Zoom users.
+ let pending_users = zoom
+ .users()
+ .get_all(
+ zoom_api::types::UsersStatus::Pending,
+ "", // role id
+ zoom_api::types::UsersIncludeFields::HostKey,
+ )
+ .await
+ .unwrap();
+ for r in pending_users {
+ zoom_users_pending.insert(r.email.to_string(), r);
+ }
}
// Get the existing GSuite users.
@@ -1725,6 +1740,11 @@ pub async fn sync_users(
// See if we have a zoom user for the user.
if let Some(zoom_user) = zoom_users.get(&user.email) {
user.zoom_id = zoom_user.id.to_string();
+ } else {
+ // See if we have a pending zoom user for the user.
+ if let Some(zoom_user) = zoom_users_pending.get(&user.email) {
+ user.zoom_id = zoom_user.id.to_string();
+ }
}
// See if we have a gusto user for the user.
@@ -1876,8 +1896,15 @@ pub async fn sync_users(
// We have the user, we don't need to do anything.
Some(zoom_user) => {
new_user.zoom_id = zoom_user.id.to_string();
+
+ // TODO: fixup the vanity URL to be their username.
+ // We only do this here, since we can't do it until the
+ // user has activated their account.
}
None => {
+ // Only create the user if we don't already have a pending user.
+ // We can know this if the zoom_id is empty.
+ if new_user.zoom_id.is_empty() {
println!("creating new zoom user {}", new_user.username);
let zoom_user = zoom
@@ -1902,8 +1929,7 @@ pub async fn sync_users(
// Set the id of the new zoom user.
new_user.zoom_id = zoom_user.id.to_string();
-
- // TODO: fixup the vanity URL to be their username.
+ }
}
}
}
