mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 08:12:24 +00:00
Remove xml TextNode
This commit is contained in:
@@ -5,12 +5,12 @@ use anyhow::anyhow;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use rustical_auth::AuthInfo;
|
use rustical_auth::AuthInfo;
|
||||||
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
|
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
|
||||||
use rustical_dav::xml_snippets::{HrefElement, TextNode};
|
use rustical_dav::xml::HrefElement;
|
||||||
use rustical_store::calendar::Calendar;
|
use rustical_store::calendar::Calendar;
|
||||||
use rustical_store::CalendarStore;
|
use rustical_store::CalendarStore;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use strum::{EnumString, IntoStaticStr, VariantNames};
|
use strum::{EnumString, VariantNames};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
pub struct CalendarResource<C: CalendarStore + ?Sized> {
|
pub struct CalendarResource<C: CalendarStore + ?Sized> {
|
||||||
@@ -116,7 +116,7 @@ impl Default for UserPrivilegeSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(EnumString, Debug, VariantNames, IntoStaticStr, Clone)]
|
#[derive(EnumString, Debug, VariantNames, Clone)]
|
||||||
#[strum(serialize_all = "kebab-case")]
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum CalendarPropName {
|
pub enum CalendarPropName {
|
||||||
Resourcetype,
|
Resourcetype,
|
||||||
@@ -140,15 +140,15 @@ pub enum CalendarProp {
|
|||||||
Resourcetype(Resourcetype),
|
Resourcetype(Resourcetype),
|
||||||
CurrentUserPrincipal(HrefElement),
|
CurrentUserPrincipal(HrefElement),
|
||||||
Owner(HrefElement),
|
Owner(HrefElement),
|
||||||
Displayname(TextNode),
|
Displayname(Option<String>),
|
||||||
#[serde(rename = "IC:calendar-color", alias = "calendar-color")]
|
#[serde(rename = "IC:calendar-color", alias = "calendar-color")]
|
||||||
CalendarColor(TextNode),
|
CalendarColor(Option<String>),
|
||||||
#[serde(rename = "C:calendar-description", alias = "calendar-description")]
|
#[serde(rename = "C:calendar-description", alias = "calendar-description")]
|
||||||
CalendarDescription(TextNode),
|
CalendarDescription(Option<String>),
|
||||||
#[serde(rename = "C:calendar-timezone", alias = "calendar-timezone")]
|
#[serde(rename = "C:calendar-timezone", alias = "calendar-timezone")]
|
||||||
CalendarTimezone(TextNode),
|
CalendarTimezone(Option<String>),
|
||||||
#[serde(rename = "IC:calendar-order", alias = "calendar-order")]
|
#[serde(rename = "IC:calendar-order", alias = "calendar-order")]
|
||||||
CalendarOrder(TextNode),
|
CalendarOrder(Option<String>),
|
||||||
#[serde(
|
#[serde(
|
||||||
rename = "C:supported-calendar-component-set",
|
rename = "C:supported-calendar-component-set",
|
||||||
alias = "supported-calendar-component-set"
|
alias = "supported-calendar-component-set"
|
||||||
@@ -159,8 +159,8 @@ pub enum CalendarProp {
|
|||||||
alias = "supported-calendar-data"
|
alias = "supported-calendar-data"
|
||||||
)]
|
)]
|
||||||
SupportedCalendarData(SupportedCalendarData),
|
SupportedCalendarData(SupportedCalendarData),
|
||||||
Getcontenttype(TextNode),
|
Getcontenttype(String),
|
||||||
MaxResourceSize(TextNode),
|
MaxResourceSize(String),
|
||||||
CurrentUserPrivilegeSet(UserPrivilegeSet),
|
CurrentUserPrivilegeSet(UserPrivilegeSet),
|
||||||
#[serde(other)]
|
#[serde(other)]
|
||||||
Invalid,
|
Invalid,
|
||||||
@@ -196,21 +196,21 @@ impl Resource for CalendarFile {
|
|||||||
"{}/{}/",
|
"{}/{}/",
|
||||||
prefix, self.principal
|
prefix, self.principal
|
||||||
)))),
|
)))),
|
||||||
CalendarPropName::Displayname => Ok(CalendarProp::Displayname(TextNode(
|
CalendarPropName::Displayname => {
|
||||||
self.calendar.name.clone(),
|
Ok(CalendarProp::Displayname(self.calendar.name.clone()))
|
||||||
))),
|
}
|
||||||
CalendarPropName::CalendarColor => Ok(CalendarProp::CalendarColor(TextNode(
|
CalendarPropName::CalendarColor => {
|
||||||
self.calendar.color.clone(),
|
Ok(CalendarProp::CalendarColor(self.calendar.color.clone()))
|
||||||
))),
|
}
|
||||||
CalendarPropName::CalendarDescription => Ok(CalendarProp::CalendarDescription(
|
CalendarPropName::CalendarDescription => Ok(CalendarProp::CalendarDescription(
|
||||||
TextNode(self.calendar.description.clone()),
|
self.calendar.description.clone(),
|
||||||
)),
|
)),
|
||||||
CalendarPropName::CalendarTimezone => Ok(CalendarProp::CalendarTimezone(TextNode(
|
CalendarPropName::CalendarTimezone => Ok(CalendarProp::CalendarTimezone(
|
||||||
self.calendar.timezone.clone(),
|
self.calendar.timezone.clone(),
|
||||||
))),
|
)),
|
||||||
CalendarPropName::CalendarOrder => Ok(CalendarProp::CalendarOrder(TextNode(
|
CalendarPropName::CalendarOrder => Ok(CalendarProp::CalendarOrder(
|
||||||
format!("{}", self.calendar.order).into(),
|
format!("{}", self.calendar.order).into(),
|
||||||
))),
|
)),
|
||||||
CalendarPropName::SupportedCalendarComponentSet => Ok(
|
CalendarPropName::SupportedCalendarComponentSet => Ok(
|
||||||
CalendarProp::SupportedCalendarComponentSet(SupportedCalendarComponentSet {
|
CalendarProp::SupportedCalendarComponentSet(SupportedCalendarComponentSet {
|
||||||
comp: vec![SupportedCalendarComponent {
|
comp: vec![SupportedCalendarComponent {
|
||||||
@@ -221,12 +221,12 @@ impl Resource for CalendarFile {
|
|||||||
CalendarPropName::SupportedCalendarData => Ok(CalendarProp::SupportedCalendarData(
|
CalendarPropName::SupportedCalendarData => Ok(CalendarProp::SupportedCalendarData(
|
||||||
SupportedCalendarData::default(),
|
SupportedCalendarData::default(),
|
||||||
)),
|
)),
|
||||||
CalendarPropName::Getcontenttype => Ok(CalendarProp::Getcontenttype(TextNode(Some(
|
CalendarPropName::Getcontenttype => Ok(CalendarProp::Getcontenttype(
|
||||||
"text/calendar;charset=utf-8".to_owned(),
|
"text/calendar;charset=utf-8".to_owned(),
|
||||||
)))),
|
)),
|
||||||
CalendarPropName::MaxResourceSize => Ok(CalendarProp::MaxResourceSize(TextNode(Some(
|
CalendarPropName::MaxResourceSize => {
|
||||||
"10000000".to_owned(),
|
Ok(CalendarProp::MaxResourceSize("10000000".to_owned()))
|
||||||
)))),
|
}
|
||||||
CalendarPropName::CurrentUserPrivilegeSet => Ok(CalendarProp::CurrentUserPrivilegeSet(
|
CalendarPropName::CurrentUserPrivilegeSet => Ok(CalendarProp::CurrentUserPrivilegeSet(
|
||||||
UserPrivilegeSet::default(),
|
UserPrivilegeSet::default(),
|
||||||
)),
|
)),
|
||||||
@@ -238,23 +238,23 @@ impl Resource for CalendarFile {
|
|||||||
CalendarProp::Resourcetype(_) => Err(rustical_dav::Error::PropReadOnly),
|
CalendarProp::Resourcetype(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||||
CalendarProp::CurrentUserPrincipal(_) => Err(rustical_dav::Error::PropReadOnly),
|
CalendarProp::CurrentUserPrincipal(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||||
CalendarProp::Owner(_) => Err(rustical_dav::Error::PropReadOnly),
|
CalendarProp::Owner(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||||
CalendarProp::Displayname(TextNode(name)) => {
|
CalendarProp::Displayname(name) => {
|
||||||
self.calendar.name = name;
|
self.calendar.name = name;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
CalendarProp::CalendarColor(TextNode(color)) => {
|
CalendarProp::CalendarColor(color) => {
|
||||||
self.calendar.color = color;
|
self.calendar.color = color;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
CalendarProp::CalendarDescription(TextNode(description)) => {
|
CalendarProp::CalendarDescription(description) => {
|
||||||
self.calendar.description = description;
|
self.calendar.description = description;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
CalendarProp::CalendarTimezone(TextNode(timezone)) => {
|
CalendarProp::CalendarTimezone(timezone) => {
|
||||||
self.calendar.timezone = timezone;
|
self.calendar.timezone = timezone;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
CalendarProp::CalendarOrder(TextNode(order)) => {
|
CalendarProp::CalendarOrder(order) => {
|
||||||
self.calendar.order = match order {
|
self.calendar.order = match order {
|
||||||
Some(order) => order.parse().map_err(|_e| anyhow!("invalid order"))?,
|
Some(order) => order.parse().map_err(|_e| anyhow!("invalid order"))?,
|
||||||
None => 0,
|
None => 0,
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ use anyhow::anyhow;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use rustical_auth::AuthInfo;
|
use rustical_auth::AuthInfo;
|
||||||
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
|
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
|
||||||
use rustical_dav::xml_snippets::TextNode;
|
|
||||||
use rustical_store::event::Event;
|
use rustical_store::event::Event;
|
||||||
use rustical_store::CalendarStore;
|
use rustical_store::CalendarStore;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use strum::{EnumString, IntoStaticStr, VariantNames};
|
use strum::{EnumString, VariantNames};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
pub struct EventResource<C: CalendarStore + ?Sized> {
|
pub struct EventResource<C: CalendarStore + ?Sized> {
|
||||||
@@ -19,7 +18,7 @@ pub struct EventResource<C: CalendarStore + ?Sized> {
|
|||||||
pub uid: String,
|
pub uid: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(EnumString, Debug, VariantNames, IntoStaticStr, Clone)]
|
#[derive(EnumString, Debug, VariantNames, Clone)]
|
||||||
#[strum(serialize_all = "kebab-case")]
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum EventPropName {
|
pub enum EventPropName {
|
||||||
Getetag,
|
Getetag,
|
||||||
@@ -27,13 +26,13 @@ pub enum EventPropName {
|
|||||||
Getcontenttype,
|
Getcontenttype,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, Clone, IntoStaticStr)]
|
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum EventProp {
|
pub enum EventProp {
|
||||||
Getetag(TextNode),
|
Getetag(String),
|
||||||
#[serde(rename = "C:calendar-data")]
|
#[serde(rename = "C:calendar-data")]
|
||||||
CalendarData(TextNode),
|
CalendarData(String),
|
||||||
Getcontenttype(TextNode),
|
Getcontenttype(String),
|
||||||
#[serde(other)]
|
#[serde(other)]
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
@@ -61,13 +60,13 @@ impl Resource for EventFile {
|
|||||||
|
|
||||||
fn get_prop(&self, _prefix: &str, prop: Self::PropName) -> Result<Self::Prop, Self::Error> {
|
fn get_prop(&self, _prefix: &str, prop: Self::PropName) -> Result<Self::Prop, Self::Error> {
|
||||||
match prop {
|
match prop {
|
||||||
EventPropName::Getetag => Ok(EventProp::Getetag(TextNode(Some(self.event.get_etag())))),
|
EventPropName::Getetag => Ok(EventProp::Getetag(self.event.get_etag())),
|
||||||
EventPropName::CalendarData => Ok(EventProp::CalendarData(TextNode(Some(
|
EventPropName::CalendarData => {
|
||||||
self.event.get_ics().to_owned(),
|
Ok(EventProp::CalendarData(self.event.get_ics().to_owned()))
|
||||||
)))),
|
}
|
||||||
EventPropName::Getcontenttype => Ok(EventProp::Getcontenttype(TextNode(Some(
|
EventPropName::Getcontenttype => Ok(EventProp::Getcontenttype(
|
||||||
"text/calendar;charset=utf-8".to_owned(),
|
"text/calendar;charset=utf-8".to_owned(),
|
||||||
)))),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,5 +10,3 @@ impl HrefElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
||||||
pub struct TextNode(pub Option<String>);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user