From 6e21a18165096c75fc4831fccf0a68cab91edead Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Fri, 18 Jun 2021 12:02:37 +0100 Subject: [PATCH] daemon: change user retrieval `get_user` should return `Person`, and we add `get_local` which gets a `LocalIdentity`. Signed-off-by: Fintan Halpenny --- daemon/src/state.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/daemon/src/state.rs b/daemon/src/state.rs index 9edd3b76e..08131abfc 100644 --- a/daemon/src/state.rs +++ b/daemon/src/state.rs @@ -358,17 +358,30 @@ where /// Get the user found at `urn`. /// /// # Errors +/// * Storage access fails +pub async fn get_user(peer: &Peer, urn: Urn) -> Result, Error> +where + S: Clone + Signer, +{ + peer.using_storage(move |store| identities::person::get(store, &urn)) + .await? + .map_err(Error::from) +} + +/// Get the local user found at `urn`. /// -/// * Resolving the user fails. -/// * Could not successfully acquire a lock to the API. -pub async fn get_user(peer: &Peer, urn: Urn) -> Result, Error> +/// # Errors +/// * Storage access fails +pub async fn get_local(peer: &Peer, urn: Urn) -> Result, Error> where S: Clone + Signer, { - peer.using_storage(move |store| match identities::person::get(store, &urn)? { - None => Ok(None), - Some(person) => local::load(store, person.urn()), - }) + peer.using_storage( + move |store| match identities::person::verify(store, &urn)? { + None => Ok(None), + Some(person) => local::load(store, person.urn()), + }, + ) .await? .map_err(Error::from) }