Some refactoring work

This commit is contained in:
Lennart
2025-05-02 19:53:02 +02:00
parent 32e1ce85f1
commit c9683580eb
8 changed files with 94 additions and 109 deletions

View File

@@ -7,8 +7,7 @@ use actix_web::{HttpRequest, http::StatusCode};
use rustical_dav::{
resource::Resource,
xml::{
MultistatusElement, PropElement, PropfindType, multistatus::ResponseElement,
sync_collection::SyncCollectionRequest,
MultistatusElement, multistatus::ResponseElement, sync_collection::SyncCollectionRequest,
},
};
use rustical_store::{
@@ -18,30 +17,14 @@ use rustical_store::{
};
pub async fn handle_sync_collection<C: CalendarStore>(
sync_collection: SyncCollectionRequest<ReportPropName>,
sync_collection: &SyncCollectionRequest<ReportPropName>,
props: &[&str],
req: HttpRequest,
user: &User,
principal: &str,
cal_id: &str,
cal_store: &C,
) -> Result<MultistatusElement<CalendarObjectPropWrapper, String>, Error> {
let props = match sync_collection.prop {
PropfindType::Allprop => {
vec!["allprop".to_owned()]
}
PropfindType::Propname => {
vec!["propname".to_owned()]
}
PropfindType::Prop(PropElement(prop_tags)) => prop_tags
.into_iter()
.map(|propname| match propname {
ReportPropName::Propname(propname) => propname.0,
ReportPropName::CalendarData(_) => "calendar-data".to_owned(),
})
.collect(),
};
let props: Vec<&str> = props.iter().map(String::as_str).collect();
let old_synctoken = parse_synctoken(&sync_collection.sync_token).unwrap_or(0);
let (new_objects, deleted_objects, new_synctoken) = cal_store
.sync_changes(principal, cal_id, old_synctoken)
@@ -59,7 +42,7 @@ pub async fn handle_sync_collection<C: CalendarStore>(
object,
principal: principal.to_owned(),
}
.propfind(&path, &props, user, req.resource_map())?,
.propfind(&path, props, user, req.resource_map())?,
);
}