mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
birthday calendar, lots of refactoring
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
address_object::resource::{AddressObjectProp, AddressObjectResource},
|
||||
principal::PrincipalResource,
|
||||
Error,
|
||||
};
|
||||
use actix_web::{
|
||||
@@ -10,8 +9,7 @@ use actix_web::{
|
||||
};
|
||||
use rustical_dav::{
|
||||
resource::{CommonPropertiesProp, EitherProp, Resource},
|
||||
xml::{multistatus::ResponseElement, MultistatusElement},
|
||||
xml::{PropElement, PropfindType},
|
||||
xml::{multistatus::ResponseElement, MultistatusElement, PropElement, PropfindType},
|
||||
};
|
||||
use rustical_store::{auth::User, AddressObject, AddressbookStore};
|
||||
use rustical_xml::XmlDeserialize;
|
||||
@@ -27,13 +25,12 @@ pub struct AddressbookMultigetRequest {
|
||||
|
||||
pub async fn get_objects_addressbook_multiget<AS: AddressbookStore + ?Sized>(
|
||||
addressbook_multiget: &AddressbookMultigetRequest,
|
||||
principal_url: &str,
|
||||
path: &str,
|
||||
principal: &str,
|
||||
addressbook_id: &str,
|
||||
store: &AS,
|
||||
) -> Result<(Vec<AddressObject>, Vec<String>), Error> {
|
||||
let resource_def =
|
||||
ResourceDef::prefix(principal_url).join(&ResourceDef::new("/{addressbook_id}/{object_id}"));
|
||||
let resource_def = ResourceDef::prefix(path).join(&ResourceDef::new("/{object_id}"));
|
||||
|
||||
let mut result = vec![];
|
||||
let mut not_found = vec![];
|
||||
@@ -67,15 +64,9 @@ pub async fn handle_addressbook_multiget<AS: AddressbookStore + ?Sized>(
|
||||
addr_store: &AS,
|
||||
) -> Result<MultistatusElement<EitherProp<AddressObjectProp, CommonPropertiesProp>, String>, Error>
|
||||
{
|
||||
let principal_url = PrincipalResource::get_url(req.resource_map(), vec![principal]).unwrap();
|
||||
let (objects, not_found) = get_objects_addressbook_multiget(
|
||||
&addr_multiget,
|
||||
&principal_url,
|
||||
principal,
|
||||
cal_id,
|
||||
addr_store,
|
||||
)
|
||||
.await?;
|
||||
let (objects, not_found) =
|
||||
get_objects_addressbook_multiget(&addr_multiget, req.path(), principal, cal_id, addr_store)
|
||||
.await?;
|
||||
|
||||
let props = match addr_multiget.prop {
|
||||
PropfindType::Allprop => {
|
||||
|
||||
@@ -83,11 +83,7 @@ pub async fn handle_sync_collection<AS: AddressbookStore + ?Sized>(
|
||||
|
||||
let mut responses = Vec::new();
|
||||
for object in new_objects {
|
||||
let path = AddressObjectResource::get_url(
|
||||
req.resource_map(),
|
||||
vec![principal, addressbook_id, &object.get_id()],
|
||||
)
|
||||
.unwrap();
|
||||
let path = format!("{}/{}", req.path().trim_end_matches('/'), object.get_id());
|
||||
responses.push(
|
||||
AddressObjectResource {
|
||||
object,
|
||||
@@ -98,11 +94,7 @@ pub async fn handle_sync_collection<AS: AddressbookStore + ?Sized>(
|
||||
}
|
||||
|
||||
for object_id in deleted_objects {
|
||||
let path = AddressObjectResource::get_url(
|
||||
req.resource_map(),
|
||||
vec![principal, addressbook_id, &object_id],
|
||||
)
|
||||
.unwrap();
|
||||
let path = format!("{}/{}", req.path().trim_end_matches('/'), object_id);
|
||||
responses.push(ResponseElement {
|
||||
href: path,
|
||||
status: Some(StatusCode::NOT_FOUND),
|
||||
|
||||
Reference in New Issue
Block a user