birthday_calendar: Refactor insert_birthday_calendar

This commit is contained in:
Lennart
2025-11-22 18:32:53 +01:00
parent ba3b64a9c4
commit 96f221f721
3 changed files with 5 additions and 3 deletions

1
Cargo.lock generated
View File

@@ -3230,6 +3230,7 @@ dependencies = [
"rustical_store_sqlite",
"rustical_xml",
"serde",
"sha2",
"thiserror 2.0.17",
"tokio",
"tower",

View File

@@ -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())
};

View File

@@ -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(())
}