use crate::{Error, calendar_object::CalendarObjectPropWrapperName}; use rustical_dav::xml::PropfindType; use rustical_ical::CalendarObject; use rustical_store::CalendarStore; use rustical_xml::XmlDeserialize; #[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)] #[allow(dead_code)] // pub struct CalendarMultigetRequest { #[xml(ty = "untagged")] pub(crate) prop: PropfindType, #[xml(flatten)] #[xml(ns = "rustical_dav::namespace::NS_DAV")] pub(crate) href: Vec, } pub async fn get_objects_calendar_multiget( cal_query: &CalendarMultigetRequest, path: &str, principal: &str, cal_id: &str, store: &C, ) -> Result<(Vec, Vec), Error> { let mut result = vec![]; let mut not_found = vec![]; for href in &cal_query.href { if let Some(filename) = href.strip_prefix(path) { let filename = filename.trim_start_matches('/'); if let Some(object_id) = filename.strip_suffix(".ics") { match store.get_object(principal, cal_id, object_id, false).await { Ok(object) => result.push(object), Err(rustical_store::Error::NotFound) => not_found.push(href.to_owned()), Err(err) => return Err(err.into()), } } else { not_found.push(href.to_owned()); } } else { not_found.push(href.to_owned()); } } Ok((result, not_found)) }