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

Function resolve_author_for

libatomic/src/daemon/services.rs:1384–1405  ·  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

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