mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
caldav: Add some properties in preparation for WebDAV Push
This commit is contained in:
@@ -87,28 +87,17 @@ pub enum Transport {
|
||||
WebPush,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
pub struct TransportWrapper {
|
||||
#[xml(ty = "untagged")]
|
||||
transport: Transport,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
pub struct Transports {
|
||||
// NOTE: Here we implement an older version of the spec since the new property name is not reflected
|
||||
// in DAVx5 yet
|
||||
// https://github.com/bitfireAT/webdav-push/commit/461259a2f2174454b2b00033419b11fac52b79e3
|
||||
#[xml(flatten, rename = b"transport")]
|
||||
#[xml(flatten, ty = "untagged")]
|
||||
#[xml(ns = "rustical_dav::namespace::NS_DAVPUSH")]
|
||||
transports: Vec<TransportWrapper>,
|
||||
transports: Vec<Transport>,
|
||||
}
|
||||
|
||||
impl Default for Transports {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
transports: vec![TransportWrapper {
|
||||
transport: Transport::WebPush,
|
||||
}],
|
||||
transports: vec![Transport::WebPush],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use rustical_dav::xml::{HrefElement, Resourcetype, ResourcetypeInner};
|
||||
use rustical_store::auth::User;
|
||||
use rustical_store::{Calendar, CalendarStore};
|
||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
||||
@@ -48,10 +49,11 @@ pub enum CalendarProp {
|
||||
// NOTE: Here we implement an older version of the spec since the new property name is not reflected
|
||||
// in DAVx5 yet
|
||||
// https://github.com/bitfireAT/webdav-push/commit/461259a2f2174454b2b00033419b11fac52b79e3
|
||||
// #[xml(skip_deserializing)]
|
||||
// #[xml(ns = "rustical_dav::namespace::NS_DAVPUSH")]
|
||||
// Transports(Transports),
|
||||
// Topic(String),
|
||||
#[xml(skip_deserializing)]
|
||||
#[xml(ns = "rustical_dav::namespace::NS_DAVPUSH")]
|
||||
Transports(Transports),
|
||||
#[xml(ns = "rustical_dav::namespace::NS_DAVPUSH")]
|
||||
Topic(String),
|
||||
|
||||
// CalDAV (RFC 4791)
|
||||
#[xml(ns = "rustical_dav::namespace::NS_ICAL")]
|
||||
@@ -153,14 +155,15 @@ impl Resource for CalendarResource {
|
||||
CalendarPropName::Getcontenttype => {
|
||||
CalendarProp::Getcontenttype("text/calendar;charset=utf-8")
|
||||
}
|
||||
// CalendarPropName::Transports => CalendarProp::Transports(Default::default()),
|
||||
// CalendarPropName::Topic => {
|
||||
// let url = CalendarResource::get_url(rmap, [&self.0.principal, &self.0.id]).unwrap();
|
||||
// let mut hasher = Sha256::new();
|
||||
// hasher.update(url);
|
||||
// let topic = format!("{:x}", hasher.finalize());
|
||||
// CalendarProp::Topic(topic)
|
||||
// }
|
||||
CalendarPropName::Transports => CalendarProp::Transports(Default::default()),
|
||||
CalendarPropName::Topic => {
|
||||
// TODO: Add salt since this could be public
|
||||
let url = CalendarResource::get_url(rmap, [&self.0.principal, &self.0.id]).unwrap();
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(url);
|
||||
let topic = format!("{:x}", hasher.finalize());
|
||||
CalendarProp::Topic(topic)
|
||||
}
|
||||
CalendarPropName::MaxResourceSize => CalendarProp::MaxResourceSize(10000000),
|
||||
CalendarPropName::SupportedReportSet => {
|
||||
CalendarProp::SupportedReportSet(SupportedReportSet::default())
|
||||
@@ -205,8 +208,8 @@ impl Resource for CalendarResource {
|
||||
}
|
||||
CalendarProp::SupportedCalendarData(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarProp::Getcontenttype(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
// CalendarProp::Transports(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
// CalendarProp::Topic(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarProp::Transports(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarProp::Topic(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarProp::MaxResourceSize(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarProp::SupportedReportSet(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarProp::SyncToken(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
@@ -247,8 +250,8 @@ impl Resource for CalendarResource {
|
||||
}
|
||||
CalendarPropName::SupportedCalendarData => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarPropName::Getcontenttype => Err(rustical_dav::Error::PropReadOnly),
|
||||
// CalendarPropName::Transports => Err(rustical_dav::Error::PropReadOnly),
|
||||
// CalendarPropName::Topic => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarPropName::Transports => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarPropName::Topic => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarPropName::MaxResourceSize => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarPropName::SupportedReportSet => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarPropName::SyncToken => Err(rustical_dav::Error::PropReadOnly),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use quick_xml::name::Namespace;
|
||||
|
||||
pub const NS_DAV: Namespace = Namespace(b"DAV:");
|
||||
pub const NS_DAVPUSH: Namespace = Namespace(b"DAV:Push");
|
||||
pub const NS_DAVPUSH: Namespace = Namespace(b"https://bitfire.at/webdav-push");
|
||||
pub const NS_CALDAV: Namespace = Namespace(b"urn:ietf:params:xml:ns:caldav");
|
||||
pub const NS_CARDDAV: Namespace = Namespace(b"urn:ietf:params:xml:ns:carddav");
|
||||
pub const NS_ICAL: Namespace = Namespace(b"http://apple.com/ns/ical/");
|
||||
|
||||
Reference in New Issue
Block a user