MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_author_for

Function resolve_author_for

libatomic/src/daemon/services.rs:1385–1406  ·  view source on GitHub ↗

Authorship for a record: an explicit wire author wins; else a named identity from the serving host's store; else the default identity.

(
    author: Option<&crate::atomic::Author>,
    identity_name: Option<&str>,
)

Source from the content-addressed store, hash-verified

1383/// Authorship for a record: an explicit wire author wins; else a named
1384/// identity from the serving host's store; else the default identity.
1385fn resolve_author_for(
1386 author: Option<&crate::atomic::Author>,
1387 identity_name: Option<&str>,
1388) -> Result<Option<Author>, String> {
1389 if let Some(author) = author {
1390 return Ok(Some(Author {
1391 name: author.name.clone(),
1392 email: author.email.clone(),
1393 identity: None,
1394 }));
1395 }
1396 if let Some(name) = identity_name {
1397 let store = IdentityStore::open_default().map_err(|e| e.to_string())?;
1398 let identity = store.load_by_name(name).map_err(|e| e.to_string())?;
1399 return Ok(Some(Author::with_identity(
1400 identity.name.clone(),
1401 identity.email.clone(),
1402 identity.public_key_base32(),
1403 )));
1404 }
1405 resolve_author()
1406}
1407
1408#[tonic::async_trait]
1409impl repository_mutation_service_server::RepositoryMutationService for MutationImpl {

Callers 1

recordMethod · 0.85

Calls 4

resolve_authorFunction · 0.85
load_by_nameMethod · 0.80
public_key_base32Method · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected