mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 08:52:16 +00:00
birthday_calendar: Refactor insert_birthday_calendar
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3230,6 +3230,7 @@ dependencies = [
|
||||
"rustical_store_sqlite",
|
||||
"rustical_xml",
|
||||
"serde",
|
||||
"sha2",
|
||||
"thiserror 2.0.17",
|
||||
"tokio",
|
||||
"tower",
|
||||
|
||||
@@ -118,15 +118,16 @@ impl SqliteAddressbookStore {
|
||||
#[instrument]
|
||||
pub async fn _insert_birthday_calendar<'e, E: Executor<'e, Database = Sqlite>>(
|
||||
executor: E,
|
||||
addressbook: Addressbook,
|
||||
addressbook: &Addressbook,
|
||||
) -> Result<(), rustical_store::Error> {
|
||||
let birthday_name = addressbook
|
||||
.displayname
|
||||
.as_ref()
|
||||
.map(|name| format!("{name} birthdays"));
|
||||
let birthday_push_topic = {
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update("birthdays");
|
||||
hasher.update(addressbook.push_topic);
|
||||
hasher.update(&addressbook.push_topic);
|
||||
format!("{:x}", hasher.finalize())
|
||||
};
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ impl AddressbookStore for SqliteAddressbookStore {
|
||||
.await
|
||||
.map_err(crate::Error::from)?;
|
||||
Self::_insert_addressbook(&mut *tx, &addressbook).await?;
|
||||
Self::_insert_birthday_calendar(&mut *tx, addressbook).await?;
|
||||
Self::_insert_birthday_calendar(&mut *tx, &addressbook).await?;
|
||||
tx.commit().await.map_err(crate::Error::from)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user