From bf5bdb96bcbc160b2ed1cfa63f3d325623e9c0c6 Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Wed, 31 Dec 2025 13:07:43 +0100 Subject: [PATCH] implement param-filter for caldav --- .../methods/report/calendar_query/elements.rs | 18 ++++++++++++++++++ .../report/calendar_query/prop_filter.rs | 8 +++++++- .../report/addressbook_query/elements.rs | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/caldav/src/calendar/methods/report/calendar_query/elements.rs b/crates/caldav/src/calendar/methods/report/calendar_query/elements.rs index d569e6d..9c9820b 100644 --- a/crates/caldav/src/calendar/methods/report/calendar_query/elements.rs +++ b/crates/caldav/src/calendar/methods/report/calendar_query/elements.rs @@ -1,5 +1,6 @@ use super::comp_filter::{CompFilterElement, CompFilterable}; use crate::calendar_object::CalendarObjectPropWrapperName; +use ical::property::Property; use rustical_dav::xml::{PropfindType, TextMatchElement}; use rustical_ical::{CalendarObject, UtcDateTime}; use rustical_store::calendar_store::CalendarQuery; @@ -27,6 +28,23 @@ pub struct ParamFilterElement { pub(crate) name: String, } +impl ParamFilterElement { + #[must_use] + pub fn match_property(&self, prop: &Property) -> bool { + let Some(param) = prop.get_param(&self.name) else { + return self.is_not_defined.is_some(); + }; + if self.is_not_defined.is_some() { + return false; + } + + let Some(text_match) = self.text_match.as_ref() else { + return true; + }; + text_match.match_text(param) + } +} + #[derive(XmlDeserialize, Clone, Debug, PartialEq)] #[allow(dead_code)] // https://datatracker.ietf.org/doc/html/rfc4791#section-9.7 diff --git a/crates/caldav/src/calendar/methods/report/calendar_query/prop_filter.rs b/crates/caldav/src/calendar/methods/report/calendar_query/prop_filter.rs index a4ae647..3a074ce 100644 --- a/crates/caldav/src/calendar/methods/report/calendar_query/prop_filter.rs +++ b/crates/caldav/src/calendar/methods/report/calendar_query/prop_filter.rs @@ -67,7 +67,13 @@ impl PropFilterElement { return false; } - // TODO: param-filter + if !self + .param_filter + .iter() + .all(|param_filter| param_filter.match_property(property)) + { + return false; + } true } diff --git a/crates/carddav/src/addressbook/methods/report/addressbook_query/elements.rs b/crates/carddav/src/addressbook/methods/report/addressbook_query/elements.rs index 03d5c4d..7ac2bc7 100644 --- a/crates/carddav/src/addressbook/methods/report/addressbook_query/elements.rs +++ b/crates/carddav/src/addressbook/methods/report/addressbook_query/elements.rs @@ -30,6 +30,7 @@ pub struct ParamFilterElement { } impl ParamFilterElement { + #[must_use] pub fn match_property(&self, prop: &Property) -> bool { let Some(param) = prop.get_param(&self.name) else { return self.is_not_defined.is_some();