implement param-filter for caldav

This commit is contained in:
Lennart
2025-12-31 13:07:43 +01:00
parent 47c2a55941
commit bf5bdb96bc
3 changed files with 26 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
use super::comp_filter::{CompFilterElement, CompFilterable}; use super::comp_filter::{CompFilterElement, CompFilterable};
use crate::calendar_object::CalendarObjectPropWrapperName; use crate::calendar_object::CalendarObjectPropWrapperName;
use ical::property::Property;
use rustical_dav::xml::{PropfindType, TextMatchElement}; use rustical_dav::xml::{PropfindType, TextMatchElement};
use rustical_ical::{CalendarObject, UtcDateTime}; use rustical_ical::{CalendarObject, UtcDateTime};
use rustical_store::calendar_store::CalendarQuery; use rustical_store::calendar_store::CalendarQuery;
@@ -27,6 +28,23 @@ pub struct ParamFilterElement {
pub(crate) name: String, 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)] #[derive(XmlDeserialize, Clone, Debug, PartialEq)]
#[allow(dead_code)] #[allow(dead_code)]
// https://datatracker.ietf.org/doc/html/rfc4791#section-9.7 // https://datatracker.ietf.org/doc/html/rfc4791#section-9.7

View File

@@ -67,7 +67,13 @@ impl PropFilterElement {
return false; return false;
} }
// TODO: param-filter if !self
.param_filter
.iter()
.all(|param_filter| param_filter.match_property(property))
{
return false;
}
true true
} }

View File

@@ -30,6 +30,7 @@ pub struct ParamFilterElement {
} }
impl ParamFilterElement { impl ParamFilterElement {
#[must_use]
pub fn match_property(&self, prop: &Property) -> bool { pub fn match_property(&self, prop: &Property) -> bool {
let Some(param) = prop.get_param(&self.name) else { let Some(param) = prop.get_param(&self.name) else {
return self.is_not_defined.is_some(); return self.is_not_defined.is_some();