Update caldata-rs

This commit is contained in:
Lennart K
2026-01-31 14:17:10 +01:00
parent cc333f7182
commit 41eed732eb
9 changed files with 21 additions and 40 deletions

View File

@@ -43,28 +43,28 @@ pub async fn route_get<C: CalendarStore, S: SubscriptionStore>(
if let Some(displayname) = calendar.meta.displayname {
props.push(ContentLine {
name: "X-WR-CALNAME".to_owned(),
value: Some(displayname),
value: displayname,
params: vec![].into(),
});
}
if let Some(description) = calendar.meta.description {
props.push(ContentLine {
name: "X-WR-CALDESC".to_owned(),
value: Some(description),
value: description,
params: vec![].into(),
});
}
if let Some(color) = calendar.meta.color {
props.push(ContentLine {
name: "X-WR-CALCOLOR".to_owned(),
value: Some(color),
value: color,
params: vec![].into(),
});
}
if let Some(timezone_id) = calendar.timezone_id {
props.push(ContentLine {
name: "X-WR-TIMEZONE".to_owned(),
value: Some(timezone_id),
value: timezone_id,
params: vec![].into(),
});
}

View File

@@ -35,16 +35,16 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
// Extract calendar metadata
let displayname = cal
.get_property("X-WR-CALNAME")
.and_then(|prop| prop.value.clone());
.map(|prop| prop.value.clone());
let description = cal
.get_property("X-WR-CALDESC")
.and_then(|prop| prop.value.clone());
.map(|prop| prop.value.clone());
let color = cal
.get_property("X-WR-CALCOLOR")
.and_then(|prop| prop.value.clone());
.map(|prop| prop.value.clone());
let timezone_id = cal
.get_property("X-WR-TIMEZONE")
.and_then(|prop| prop.value.clone());
.map(|prop| prop.value.clone());
// These properties should not appear in the expanded calendar objects
cal.remove_property("X-WR-CALNAME");
cal.remove_property("X-WR-CALDESC");

View File

@@ -34,7 +34,7 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
let mut card_mut = card.mutable();
card_mut.add_content_line(ContentLine {
name: "UID".to_owned(),
value: Some(uuid::Uuid::new_v4().to_string()),
value: uuid::Uuid::new_v4().to_string(),
params: vec![].into(),
});
card = card_mut.build(&ParserOptions::default(), None).unwrap();

View File

@@ -129,8 +129,7 @@ impl TextMatchElement {
}
#[must_use]
pub fn match_property(&self, property: &ContentLine) -> bool {
let text = property.value.as_deref().unwrap_or("");
self.match_text(text)
self.match_text(&property.value)
}
}

View File

@@ -17,7 +17,6 @@ derive_more.workspace = true
rustical_xml.workspace = true
caldata.workspace = true
regex.workspace = true
rrule.workspace = true
serde.workspace = true
sha2.workspace = true
axum.workspace = true

View File

@@ -13,7 +13,7 @@ use caldata::{
IcalUIDProperty, IcalVERSIONProperty, IcalVersion, VcardANNIVERSARYProperty,
VcardBDAYProperty, VcardFNProperty,
},
types::{CalDate, PartialDate, Timezone},
types::{CalDate, PartialDate, Tz},
};
use chrono::{NaiveDate, Utc};
use sha2::{Digest, Sha256};
@@ -73,7 +73,7 @@ impl AddressObject {
let Some(dtstart) = NaiveDate::from_ymd_opt(year.unwrap_or(1900), month, day) else {
return Ok(None);
};
let start_date = CalDate(dtstart, Timezone::Local);
let start_date = CalDate(dtstart, Tz::Local);
let Some(end_date) = start_date.succ_opt() else {
// start_date is MAX_DATE, this should never happen but FAPP also not raise an error
return Ok(None);
@@ -90,14 +90,14 @@ impl AddressObject {
IcalDTENDProperty(end_date.into(), vec![].into()).into(),
IcalUIDProperty(uid, vec![].into()).into(),
IcalRRULEProperty(
rrule::RRule::from_str("FREQ=YEARLY").unwrap(),
caldata::rrule::RRule::from_str("FREQ=YEARLY").unwrap(),
vec![].into(),
)
.into(),
IcalSUMMARYProperty(summary.clone(), vec![].into()).into(),
ContentLine {
name: "TRANSP".to_owned(),
value: Some("TRANSPARENT".to_owned()),
value: "TRANSPARENT".to_owned(),
..Default::default()
},
],
@@ -105,17 +105,17 @@ impl AddressObject {
properties: vec![
ContentLine {
name: "TRIGGER".to_owned(),
value: Some("-PT0M".to_owned()),
value: "-PT0M".to_owned(),
params: vec![("VALUE".to_owned(), vec!["DURATION".to_owned()])].into(),
},
ContentLine {
name: "ACTION".to_owned(),
value: Some("DISPLAY".to_owned()),
value: "DISPLAY".to_owned(),
..Default::default()
},
ContentLine {
name: "DESCRIPTION".to_owned(),
value: Some(summary),
value: summary,
..Default::default()
},
],

View File

@@ -27,7 +27,6 @@ rustical_dav.workspace = true
rustical_ical.workspace = true
axum.workspace = true
http.workspace = true
rrule.workspace = true
headers.workspace = true
tower.workspace = true
futures-core.workspace = true