Use a context struct

This commit is contained in:
Marc Plano-Lesay 2024-11-06 09:09:48 +11:00
parent 60208331ba
commit a0d9bfa97b
Signed by: kernald
GPG key ID: 66A41B08CC62A6CF
10 changed files with 134 additions and 45 deletions

View file

@ -10,17 +10,14 @@ use vcard4::{
};
use crate::{
context::Context,
types::{PersonResponseDto, PersonUpdateDto},
utils::people::fetch_all_contacts,
Client,
};
pub async fn sync_date_of_birth(
client: &Client,
vcard_file: &PathBuf,
dry_run: bool,
) -> Result<()> {
let server_contacts = fetch_all_contacts(client).await?;
pub async fn sync_date_of_birth(ctx: Context, vcard_file: &PathBuf) -> Result<()> {
let server_contacts = fetch_all_contacts(&ctx.client).await?;
let filtered_contacts: Vec<_> = server_contacts
.iter()
@ -55,7 +52,7 @@ pub async fn sync_date_of_birth(
formatted_name
);
} else if bday.year() > 0 {
update_person_bday(c, bday, client, dry_run).await?;
update_person_bday(c, bday, &ctx.client, ctx.dry_run).await?;
updated_dobs += 1;
} else {
debug!(