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>,
)
| 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. |
| 1384 | fn 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] |
| 1408 | impl repository_mutation_service_server::RepositoryMutationService for MutationImpl { |
no test coverage detected