Skip to content

Commit

Permalink
daemon: change user retrieval
Browse files Browse the repository at this point in the history
`get_user` should return `Person`, and we add `get_local` which gets a
`LocalIdentity`.

Signed-off-by: Fintan Halpenny <[email protected]>
  • Loading branch information
FintanH committed Jun 25, 2021
1 parent 4150d5c commit 6e21a18
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions daemon/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,30 @@ where
/// Get the user found at `urn`.
///
/// # Errors
/// * Storage access fails
pub async fn get_user<S>(peer: &Peer<S>, urn: Urn) -> Result<Option<Person>, 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<S>(peer: &Peer<S>, urn: Urn) -> Result<Option<LocalIdentity>, Error>
/// # Errors
/// * Storage access fails
pub async fn get_local<S>(peer: &Peer<S>, urn: Urn) -> Result<Option<LocalIdentity>, 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)
}
Expand Down

0 comments on commit 6e21a18

Please sign in to comment.