caldav: Support VJOURNAL

This commit is contained in:
Lennart
2024-10-27 16:32:08 +01:00
parent b35b10962b
commit 53d2ea10e6
5 changed files with 23 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ a calendar server
## Todo
- [ ] CalDAV
- [x] Support for VEVENT, VTODO
- [x] Support for VEVENT, VTODO, VJOURNAL
- [ ] Proper filtering for REPORT method
- [x] comp-filter
- [x] time-range filter

View File

@@ -143,6 +143,9 @@ impl Resource for CalendarResource {
SupportedCalendarComponent {
name: "VTODO".to_owned(),
},
SupportedCalendarComponent {
name: "VJOURNAL".to_owned(),
},
],
})
}

View File

@@ -0,0 +1,6 @@
use ical::parser::ical::component::IcalJournal;
#[derive(Debug, Clone)]
pub struct JournalObject {
pub(crate) journal: IcalJournal,
}

View File

@@ -1,5 +1,6 @@
pub mod calendar;
pub mod event;
pub mod journal;
pub mod object;
pub mod todo;

View File

@@ -1,4 +1,4 @@
use super::{event::EventObject, todo::TodoObject};
use super::{event::EventObject, journal::JournalObject, todo::TodoObject};
use crate::{timestamp::CalDateTime, Error};
use anyhow::Result;
use ical::parser::{ical::component::IcalTimeZone, Component};
@@ -18,6 +18,7 @@ pub enum CalendarObjectType {
pub enum CalendarObjectComponent {
Event(EventObject),
Todo(TodoObject),
Journal(JournalObject),
}
#[derive(Debug, Clone)]
@@ -113,6 +114,15 @@ impl CalendarObject {
data: CalendarObjectComponent::Todo(TodoObject { todo: todo.clone() }),
});
}
if let Some(journal) = cal.journals.first() {
return Ok(CalendarObject {
id: object_id,
ics,
data: CalendarObjectComponent::Journal(JournalObject {
journal: journal.clone(),
}),
});
}
Err(Error::InvalidData(
"iCalendar component type not supported :(".to_owned(),
@@ -137,6 +147,7 @@ impl CalendarObject {
match self.data {
CalendarObjectComponent::Todo(_) => "VTODO",
CalendarObjectComponent::Event(_) => "VEVENT",
CalendarObjectComponent::Journal(_) => "VJOURNAL",
}
}