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