slight report refactoring

This commit is contained in:
Lennart
2025-06-03 23:06:00 +02:00
parent 7f3ce01c2b
commit c14f98a432
4 changed files with 86 additions and 118 deletions

View File

@@ -1,19 +1,11 @@
use rustical_dav::{
resource::{PrincipalUri, Resource},
xml::{MultistatusElement, PropfindType},
};
use super::ReportPropName;
use crate::Error;
use rustical_dav::xml::PropfindType;
use rustical_ical::{CalendarObject, UtcDateTime};
use rustical_store::{CalendarStore, auth::User, calendar_store::CalendarQuery};
use rustical_store::{CalendarStore, calendar_store::CalendarQuery};
use rustical_xml::XmlDeserialize;
use std::ops::Deref;
use crate::{
Error,
calendar_object::resource::{CalendarObjectPropWrapper, CalendarObjectResource},
};
use super::ReportPropName;
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
#[allow(dead_code)]
pub(crate) struct TimeRangeElement {
@@ -212,33 +204,3 @@ pub async fn get_objects_calendar_query<C: CalendarStore>(
}
Ok(objects)
}
pub async fn handle_calendar_query<C: CalendarStore>(
cal_query: &CalendarQueryRequest,
props: &[&str],
path: &str,
puri: &impl PrincipalUri,
user: &User,
principal: &str,
cal_id: &str,
cal_store: &C,
) -> Result<MultistatusElement<CalendarObjectPropWrapper, String>, Error> {
let objects = get_objects_calendar_query(cal_query, principal, cal_id, cal_store).await?;
let mut responses = Vec::new();
for object in objects {
let path = format!("{}/{}.ics", path, object.get_id());
responses.push(
CalendarObjectResource {
object,
principal: principal.to_owned(),
}
.propfind(&path, props, puri, user)?,
);
}
Ok(MultistatusElement {
responses,
..Default::default()
})
}