mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 08:12:24 +00:00
caldav: Make supported-calendar-component-set configurable
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use super::CalendarObjectType;
|
||||
use crate::synctoken::format_synctoken;
|
||||
use chrono::NaiveDateTime;
|
||||
use serde::Serialize;
|
||||
@@ -16,6 +17,7 @@ pub struct Calendar {
|
||||
pub synctoken: i64,
|
||||
pub subscription_url: Option<String>,
|
||||
pub push_topic: String,
|
||||
pub components: Vec<CalendarObjectType>,
|
||||
}
|
||||
|
||||
impl Calendar {
|
||||
|
||||
@@ -2,10 +2,11 @@ use super::{CalDateTime, EventObject, JournalObject, TodoObject};
|
||||
use crate::Error;
|
||||
use anyhow::Result;
|
||||
use ical::parser::{ical::component::IcalTimeZone, Component};
|
||||
use serde::Serialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{collections::HashMap, io::BufReader};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
|
||||
// specified in https://datatracker.ietf.org/doc/html/rfc5545#section-3.6
|
||||
pub enum CalendarObjectType {
|
||||
Event = 0,
|
||||
@@ -13,6 +14,31 @@ pub enum CalendarObjectType {
|
||||
Journal = 2,
|
||||
}
|
||||
|
||||
impl rustical_xml::ValueSerialize for CalendarObjectType {
|
||||
fn serialize(&self) -> String {
|
||||
match self {
|
||||
CalendarObjectType::Event => "VEVENT",
|
||||
CalendarObjectType::Todo => "VTODO",
|
||||
CalendarObjectType::Journal => "VJOURNAL",
|
||||
}
|
||||
.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl rustical_xml::ValueDeserialize for CalendarObjectType {
|
||||
fn deserialize(val: &str) -> std::result::Result<Self, rustical_xml::XmlError> {
|
||||
match <String as rustical_xml::ValueDeserialize>::deserialize(val)?.as_str() {
|
||||
"VEVENT" => Ok(Self::Event),
|
||||
"VTODO" => Ok(Self::Todo),
|
||||
"VJOURNAL" => Ok(Self::Journal),
|
||||
_ => Err(rustical_xml::XmlError::Other(format!(
|
||||
"Invalid value '{}', must be VEVENT, VTODO, or VJOURNAL",
|
||||
val
|
||||
))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum CalendarObjectComponent {
|
||||
Event(EventObject),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
AddressObject, Addressbook, AddressbookStore, Calendar, CalendarObject, CalendarStore, Error,
|
||||
calendar::CalendarObjectType, AddressObject, Addressbook, AddressbookStore, Calendar,
|
||||
CalendarObject, CalendarStore, Error,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use derive_more::derive::Constructor;
|
||||
@@ -31,6 +32,7 @@ fn birthday_calendar(addressbook: Addressbook) -> Calendar {
|
||||
hasher.update(addressbook.push_topic);
|
||||
format!("{:x}", hasher.finalize())
|
||||
},
|
||||
components: vec![CalendarObjectType::Event],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user