mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 20:32:48 +00:00
Some refactoring work
This commit is contained in:
@@ -6,8 +6,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::{
|
||||
@@ -17,26 +16,14 @@ use rustical_store::{
|
||||
};
|
||||
|
||||
pub async fn handle_sync_collection<AS: AddressbookStore>(
|
||||
sync_collection: SyncCollectionRequest,
|
||||
sync_collection: &SyncCollectionRequest,
|
||||
props: &[&str],
|
||||
req: HttpRequest,
|
||||
user: &User,
|
||||
principal: &str,
|
||||
addressbook_id: &str,
|
||||
addr_store: &AS,
|
||||
) -> Result<MultistatusElement<AddressObjectPropWrapper, 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| propname.0).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) = addr_store
|
||||
.sync_changes(principal, addressbook_id, old_synctoken)
|
||||
@@ -54,7 +41,7 @@ pub async fn handle_sync_collection<AS: AddressbookStore>(
|
||||
object,
|
||||
principal: principal.to_owned(),
|
||||
}
|
||||
.propfind(&path, &props, user, req.resource_map())?,
|
||||
.propfind(&path, props, user, req.resource_map())?,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user