mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 02:22:21 +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_store_sqlite",
|
||||||
"rustical_xml",
|
"rustical_xml",
|
||||||
"serde",
|
"serde",
|
||||||
|
"sha2",
|
||||||
"thiserror 2.0.17",
|
"thiserror 2.0.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower",
|
"tower",
|
||||||
|
|||||||
@@ -118,15 +118,16 @@ impl SqliteAddressbookStore {
|
|||||||
#[instrument]
|
#[instrument]
|
||||||
pub async fn _insert_birthday_calendar<'e, E: Executor<'e, Database = Sqlite>>(
|
pub async fn _insert_birthday_calendar<'e, E: Executor<'e, Database = Sqlite>>(
|
||||||
executor: E,
|
executor: E,
|
||||||
addressbook: Addressbook,
|
addressbook: &Addressbook,
|
||||||
) -> Result<(), rustical_store::Error> {
|
) -> Result<(), rustical_store::Error> {
|
||||||
let birthday_name = addressbook
|
let birthday_name = addressbook
|
||||||
.displayname
|
.displayname
|
||||||
|
.as_ref()
|
||||||
.map(|name| format!("{name} birthdays"));
|
.map(|name| format!("{name} birthdays"));
|
||||||
let birthday_push_topic = {
|
let birthday_push_topic = {
|
||||||
let mut hasher = Sha256::new();
|
let mut hasher = Sha256::new();
|
||||||
hasher.update("birthdays");
|
hasher.update("birthdays");
|
||||||
hasher.update(addressbook.push_topic);
|
hasher.update(&addressbook.push_topic);
|
||||||
format!("{:x}", hasher.finalize())
|
format!("{:x}", hasher.finalize())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ impl AddressbookStore for SqliteAddressbookStore {
|
|||||||
.await
|
.await
|
||||||
.map_err(crate::Error::from)?;
|
.map_err(crate::Error::from)?;
|
||||||
Self::_insert_addressbook(&mut *tx, &addressbook).await?;
|
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)?;
|
tx.commit().await.map_err(crate::Error::from)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user