diff --git a/cli/src/commands/shared_recovery/info.rs b/cli/src/commands/shared_recovery/info.rs index a1f3c781989..3e6be33cdb6 100644 --- a/cli/src/commands/shared_recovery/info.rs +++ b/cli/src/commands/shared_recovery/info.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use itertools::Itertools; use crate::{build_main_with_client, utils::*}; @@ -18,6 +20,8 @@ pub async fn list_shared_recovery(_args: Args, client: &StartedClient) -> anyhow } let info = client.get_self_shamir_recovery().await?; + let users = client.list_users(false, None, None).await?; + let users: HashMap<_, _> = users.iter().map(|info| (info.id, info)).collect(); match info { libparsec_client::SelfShamirRecoveryInfo::Deleted { @@ -28,7 +32,10 @@ pub async fn list_shared_recovery(_args: Args, client: &StartedClient) -> anyhow libparsec_client::SelfShamirRecoveryInfo::SetupAllValid { per_recipient_shares, threshold, .. } => println!("Shared recovery {GREEN}set up{RESET} with threshold {threshold}\n{}", per_recipient_shares.iter().map(|(recipient, share)| { - format!("• User {recipient} has {share} share(s)") // TODO: special case if there is only on share + // this means that a user disappeared completely, it should not happen + let user= &users.get(recipient).expect("missing recipient").human_handle; + format!("\t• User {user} has {share} share(s)", // TODO: special case if there is only on share + ) }).join("\n")), libparsec_client::SelfShamirRecoveryInfo::SetupWithRevokedRecipients { threshold, diff --git a/cli/src/commands/shared_recovery/list.rs b/cli/src/commands/shared_recovery/list.rs index a6106ad232f..b766164bea8 100644 --- a/cli/src/commands/shared_recovery/list.rs +++ b/cli/src/commands/shared_recovery/list.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use itertools::Itertools; use crate::{build_main_with_client, utils::*}; @@ -18,6 +20,8 @@ pub async fn shared_recovery_info(_args: Args, client: &StartedClient) -> anyhow } let res = client.list_shamir_recoveries_for_others().await?; + let users = client.list_users(false, None, None).await?; + let users: HashMap<_, _> = users.iter().map(|info| (info.id, info)).collect(); if res.is_empty() { println!("No shared recovery found"); @@ -34,8 +38,11 @@ pub async fn shared_recovery_info(_args: Args, client: &StartedClient) -> anyhow } => println!("• Deleted shared recovery for {RED}{user_id}{RESET} - deleted by {deleted_by} on {deleted_on}"), libparsec_client::OtherShamirRecoveryInfo::SetupAllValid { user_id, threshold, per_recipient_shares,.. - } => println!("Shared recovery for {GREEN}{user_id}{RESET} with threshold {threshold}\n{}", per_recipient_shares.iter().map(|(recipient, share)| { - format!("\t• User {recipient} has {share} share(s)") // TODO: special case if there is only on share + } => println!("Shared recovery for {GREEN}{}{RESET} with threshold {threshold}\n{}", users.get(&user_id).expect("missing author").human_handle, per_recipient_shares.iter().map(|(recipient, share)| { + // this means that a user disappeared completely, it should not happen + let user= &users.get(recipient).expect("missing recipient").human_handle; + format!("\t• User {user} has {share} share(s)", // TODO: special case if there is only on share + ) }).join("\n")), libparsec_client::OtherShamirRecoveryInfo::SetupWithRevokedRecipients { user_id,