mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 11:48:18 +00:00
implement param-filter for caldav
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user