Compare commits

...

3 Commits

Author SHA1 Message Date
Lennart
8ed4db5824 work on new comp-filter implementation 2025-10-27 18:59:00 +01:00
Lennart
43d7aabf28 version 0.9.12 2025-10-21 21:06:32 +02:00
Lennart
2fc51fac66 remove duplicate statement 2025-10-21 21:04:41 +02:00
5 changed files with 119 additions and 16 deletions

22
Cargo.lock generated
View File

@@ -2989,7 +2989,7 @@ dependencies = [
[[package]]
name = "rustical"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"anyhow",
"argon2",
@@ -3032,7 +3032,7 @@ dependencies = [
[[package]]
name = "rustical_caldav"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"async-std",
"async-trait",
@@ -3072,7 +3072,7 @@ dependencies = [
[[package]]
name = "rustical_carddav"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"async-trait",
"axum",
@@ -3104,7 +3104,7 @@ dependencies = [
[[package]]
name = "rustical_dav"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"async-trait",
"axum",
@@ -3129,7 +3129,7 @@ dependencies = [
[[package]]
name = "rustical_dav_push"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"async-trait",
"axum",
@@ -3154,7 +3154,7 @@ dependencies = [
[[package]]
name = "rustical_frontend"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"askama",
"askama_web",
@@ -3187,7 +3187,7 @@ dependencies = [
[[package]]
name = "rustical_ical"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"axum",
"chrono",
@@ -3205,7 +3205,7 @@ dependencies = [
[[package]]
name = "rustical_oidc"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"async-trait",
"axum",
@@ -3221,7 +3221,7 @@ dependencies = [
[[package]]
name = "rustical_store"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"anyhow",
"async-trait",
@@ -3255,7 +3255,7 @@ dependencies = [
[[package]]
name = "rustical_store_sqlite"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"async-trait",
"chrono",
@@ -3276,7 +3276,7 @@ dependencies = [
[[package]]
name = "rustical_xml"
version = "0.9.11"
version = "0.9.12"
dependencies = [
"quick-xml",
"thiserror 2.0.16",

View File

@@ -2,7 +2,7 @@
members = ["crates/*"]
[workspace.package]
version = "0.9.11"
version = "0.9.12"
edition = "2024"
description = "A CalDAV server"
documentation = "https://lennart-k.github.io/rustical/"

View File

@@ -32,10 +32,6 @@ pub async fn route_get<C: CalendarStore, S: SubscriptionStore>(
return Err(crate::Error::Unauthorized);
}
let calendar = cal_store
.get_calendar(&principal, &calendar_id, true)
.await?;
let mut timezones = HashMap::new();
let mut vtimezones = HashMap::new();
let objects = cal_store.get_objects(&principal, &calendar_id).await?;

View File

@@ -0,0 +1,106 @@
use ical::generator::IcalEvent;
use rustical_ical::{CalendarObject, CalendarObjectComponent, CalendarObjectType};
use crate::calendar::methods::report::calendar_query::{
CompFilterElement, PropFilterElement, TimeRangeElement,
};
pub trait CompFilterable {
fn get_comp_name(&self) -> &'static str;
fn match_time_range(&self, time_range: &TimeRangeElement) -> bool;
fn match_prop_filter(&self, prop_filter: &PropFilterElement) -> bool;
fn match_subcomponents(&self, comp_filter: &CompFilterElement) -> bool;
fn matches(&self, comp_filter: &CompFilterElement) -> bool {
let name_matches = self.get_comp_name() != comp_filter.name;
match (comp_filter.is_not_defined.is_some(), name_matches) {
// We are the component that's not supposed to be defined
(true, true) => return false,
// We shall not be and indeed we aren't
(true, false) => return true,
// We don't match
(false, false) => return false,
_ => {}
}
if let Some(time_range) = comp_filter.time_range.as_ref()
&& !self.match_time_range(time_range)
{
return false;
}
for prop_filter in &comp_filter.prop_filter {
if !self.match_prop_filter(prop_filter) {
return false;
}
}
// let subcomponents = self.get_subcomponents();
// for sub_comp_filter in &comp_filter.comp_filter {
// if sub_comp_filter.is_not_defined.is_some() {
// // If is_not_defined: Filter shuold match for all
// // Confusing logic but matching also means not being the component that
// // shouldn't be defined
// if subcomponents
// .iter()
// .any(|sub| !sub.matches(sub_comp_filter))
// {
// return false;
// }
// } else {
// // otherwise if no component matches return false
// if !subcomponents.iter().any(|sub| sub.matches(sub_comp_filter)) {
// return false;
// }
// }
// }
comp_filter
.comp_filter
.iter()
.all(|filter| self.match_subcomponents(filter))
}
}
impl CompFilterable for CalendarObject {
fn get_comp_name(&self) -> &'static str {
"VCALENDAR"
}
fn match_time_range(&self, _time_range: &TimeRangeElement) -> bool {
false
}
fn match_prop_filter(&self, _prop_filter: &PropFilterElement) -> bool {
// TODO
true
}
fn match_subcomponents(&self, comp_filter: &CompFilterElement) -> bool {
self.get_data().matches(comp_filter)
}
}
impl CompFilterable for CalendarObjectComponent {
fn get_comp_name(&self) -> &'static str {
CalendarObjectType::from(self).as_str()
}
fn match_time_range(&self, time_range: &TimeRangeElement) -> bool {
// TODO
true
}
fn match_prop_filter(&self, _prop_filter: &PropFilterElement) -> bool {
// TODO
true
}
fn match_subcomponents(&self, _comp_filter: &CompFilterElement) -> bool {
// TODO: Properly check subcomponents
true
}
}

View File

@@ -4,6 +4,7 @@ use rustical_store::CalendarStore;
mod elements;
pub(crate) use elements::*;
mod comp_filter;
pub async fn get_objects_calendar_query<C: CalendarStore>(
cal_query: &CalendarQueryRequest,