mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 11:42:25 +00:00
caldav: user enums for props
This commit is contained in:
@@ -24,3 +24,4 @@ serde_json = "1.0"
|
|||||||
tokio = { version = "1.35", features = ["sync", "full"] }
|
tokio = { version = "1.35", features = ["sync", "full"] }
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
|
strum = { version = "0.26.2", features = ["strum_macros", "derive"] }
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use async_trait::async_trait;
|
|||||||
use quick_xml::{events::BytesText, Writer};
|
use quick_xml::{events::BytesText, Writer};
|
||||||
use rustical_auth::AuthInfo;
|
use rustical_auth::AuthInfo;
|
||||||
use rustical_store::calendar::{Calendar, CalendarStore};
|
use rustical_store::calendar::{Calendar, CalendarStore};
|
||||||
|
use strum::{EnumString, IntoStaticStr, VariantNames};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use crate::proptypes::{write_href_prop, write_string_prop};
|
use crate::proptypes::{write_href_prop, write_string_prop};
|
||||||
@@ -19,10 +20,27 @@ pub struct CalendarResource<C: CalendarStore + ?Sized> {
|
|||||||
pub principal: String,
|
pub principal: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(EnumString, Debug, VariantNames, IntoStaticStr)]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
|
pub enum CalendarProp {
|
||||||
|
Resourcetype,
|
||||||
|
CurrentUserPrincipal,
|
||||||
|
Displayname,
|
||||||
|
SupportedCalendarComponentSet,
|
||||||
|
SupportedCalendarData,
|
||||||
|
Getcontenttype,
|
||||||
|
CalendarDescription,
|
||||||
|
Owner,
|
||||||
|
CalendarColor,
|
||||||
|
CurrentUserPrivilegeSet,
|
||||||
|
MaxResourceSize,
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
||||||
type MemberType = Self;
|
type MemberType = Self;
|
||||||
type UriComponents = (String, String); // principal, calendar_id
|
type UriComponents = (String, String); // principal, calendar_id
|
||||||
|
type PropType = CalendarProp;
|
||||||
|
|
||||||
async fn acquire_from_request(
|
async fn acquire_from_request(
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
@@ -56,33 +74,19 @@ impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
|||||||
Ok(vec![])
|
Ok(vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
fn write_prop<W: Write>(&self, writer: &mut Writer<W>, prop: Self::PropType) -> Result<()> {
|
||||||
fn list_dead_props() -> Vec<&'static str> {
|
|
||||||
vec![
|
|
||||||
"resourcetype",
|
|
||||||
"current-user-principal",
|
|
||||||
"displayname",
|
|
||||||
"supported-calendar-component-set",
|
|
||||||
"supported-calendar-data",
|
|
||||||
"getcontenttype",
|
|
||||||
"calendar-description",
|
|
||||||
"owner",
|
|
||||||
"calendar-color",
|
|
||||||
"current-user-privilege-set",
|
|
||||||
"max-resource-size",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
fn write_prop<W: Write>(&self, writer: &mut Writer<W>, prop: &str) -> Result<()> {
|
|
||||||
match prop {
|
match prop {
|
||||||
"resourcetype" => write_resourcetype(writer, vec!["C:calendar", "collection"])?,
|
CalendarProp::Resourcetype => {
|
||||||
"current-user-principal" | "owner" => {
|
write_resourcetype(writer, vec!["C:calendar", "collection"])?
|
||||||
|
}
|
||||||
|
CalendarProp::CurrentUserPrincipal | CalendarProp::Owner => {
|
||||||
write_href_prop(
|
write_href_prop(
|
||||||
writer,
|
writer,
|
||||||
prop,
|
prop.into(),
|
||||||
&format!("{}/{}/", self.prefix, self.principal),
|
&format!("{}/{}/", self.prefix, self.principal),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
"displayname" => {
|
CalendarProp::Displayname => {
|
||||||
let el = writer.create_element("displayname");
|
let el = writer.create_element("displayname");
|
||||||
if let Some(name) = self.calendar.clone().name {
|
if let Some(name) = self.calendar.clone().name {
|
||||||
el.write_text_content(BytesText::new(&name))?;
|
el.write_text_content(BytesText::new(&name))?;
|
||||||
@@ -90,7 +94,7 @@ impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
|||||||
el.write_empty()?;
|
el.write_empty()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"calendar-color" => {
|
CalendarProp::CalendarColor => {
|
||||||
let el = writer.create_element("IC:calendar-color");
|
let el = writer.create_element("IC:calendar-color");
|
||||||
if let Some(color) = self.calendar.clone().color {
|
if let Some(color) = self.calendar.clone().color {
|
||||||
el.write_text_content(BytesText::new(&color))?;
|
el.write_text_content(BytesText::new(&color))?;
|
||||||
@@ -98,7 +102,7 @@ impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
|||||||
el.write_empty()?;
|
el.write_empty()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"calendar-description" => {
|
CalendarProp::CalendarDescription => {
|
||||||
let el = writer.create_element("C:calendar-description");
|
let el = writer.create_element("C:calendar-description");
|
||||||
if let Some(description) = self.calendar.clone().description {
|
if let Some(description) = self.calendar.clone().description {
|
||||||
el.write_text_content(BytesText::new(&description))?;
|
el.write_text_content(BytesText::new(&description))?;
|
||||||
@@ -106,7 +110,7 @@ impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
|||||||
el.write_empty()?;
|
el.write_empty()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"supported-calendar-component-set" => {
|
CalendarProp::SupportedCalendarComponentSet => {
|
||||||
writer
|
writer
|
||||||
.create_element("C:supported-calendar-component-set")
|
.create_element("C:supported-calendar-component-set")
|
||||||
.write_inner_content(|writer| {
|
.write_inner_content(|writer| {
|
||||||
@@ -117,7 +121,7 @@ impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
|||||||
Ok::<(), quick_xml::Error>(())
|
Ok::<(), quick_xml::Error>(())
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
"supported-calendar-data" => {
|
CalendarProp::SupportedCalendarData => {
|
||||||
writer
|
writer
|
||||||
.create_element("C:supported-calendar-data")
|
.create_element("C:supported-calendar-data")
|
||||||
.write_inner_content(|writer| {
|
.write_inner_content(|writer| {
|
||||||
@@ -132,13 +136,13 @@ impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
|||||||
Ok::<(), quick_xml::Error>(())
|
Ok::<(), quick_xml::Error>(())
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
"getcontenttype" => {
|
CalendarProp::Getcontenttype => {
|
||||||
write_string_prop(writer, "getcontenttype", "text/calendar")?;
|
write_string_prop(writer, "getcontenttype", "text/calendar")?;
|
||||||
}
|
}
|
||||||
"max-resource-size" => {
|
CalendarProp::MaxResourceSize => {
|
||||||
write_string_prop(writer, "max-resource-size", "10000000")?;
|
write_string_prop(writer, "max-resource-size", "10000000")?;
|
||||||
}
|
}
|
||||||
"current-user-privilege-set" => {
|
CalendarProp::CurrentUserPrivilegeSet => {
|
||||||
writer
|
writer
|
||||||
.create_element("current-user-privilege-set")
|
.create_element("current-user-privilege-set")
|
||||||
// These are just hard-coded for now and will possibly change in the future
|
// These are just hard-coded for now and will possibly change in the future
|
||||||
@@ -163,9 +167,6 @@ impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
|
|||||||
Ok::<(), quick_xml::Error>(())
|
Ok::<(), quick_xml::Error>(())
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
return Err(anyhow!("invalid prop"));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use rustical_dav::resource::Resource;
|
|||||||
use rustical_store::calendar::CalendarStore;
|
use rustical_store::calendar::CalendarStore;
|
||||||
use rustical_store::event::Event;
|
use rustical_store::event::Event;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use strum::{EnumString, VariantNames};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
pub struct EventResource<C: CalendarStore + ?Sized> {
|
pub struct EventResource<C: CalendarStore + ?Sized> {
|
||||||
@@ -15,10 +16,19 @@ pub struct EventResource<C: CalendarStore + ?Sized> {
|
|||||||
pub event: Event,
|
pub event: Event,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(EnumString, Debug, VariantNames)]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
|
pub enum EventProp {
|
||||||
|
Getetag,
|
||||||
|
CalendarData,
|
||||||
|
Getcontenttype,
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl<C: CalendarStore + ?Sized> Resource for EventResource<C> {
|
impl<C: CalendarStore + ?Sized> Resource for EventResource<C> {
|
||||||
type UriComponents = (String, String, String); // principal, calendar, event
|
type UriComponents = (String, String, String); // principal, calendar, event
|
||||||
type MemberType = Self;
|
type MemberType = Self;
|
||||||
|
type PropType = EventProp;
|
||||||
|
|
||||||
fn get_path(&self) -> &str {
|
fn get_path(&self) -> &str {
|
||||||
&self.path
|
&self.path
|
||||||
@@ -54,24 +64,19 @@ impl<C: CalendarStore + ?Sized> Resource for EventResource<C> {
|
|||||||
fn write_prop<W: std::io::Write>(
|
fn write_prop<W: std::io::Write>(
|
||||||
&self,
|
&self,
|
||||||
writer: &mut quick_xml::Writer<W>,
|
writer: &mut quick_xml::Writer<W>,
|
||||||
prop: &str,
|
prop: Self::PropType,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
match prop {
|
match prop {
|
||||||
"getetag" => {
|
EventProp::Getetag => {
|
||||||
write_string_prop(writer, "getetag", &self.event.get_etag())?;
|
write_string_prop(writer, "getetag", &self.event.get_etag())?;
|
||||||
}
|
}
|
||||||
"calendar-data" => {
|
EventProp::CalendarData => {
|
||||||
write_string_prop(writer, "C:calendar-data", &self.event.get_ics())?;
|
write_string_prop(writer, "C:calendar-data", &self.event.get_ics())?;
|
||||||
}
|
}
|
||||||
"getcontenttype" => {
|
EventProp::Getcontenttype => {
|
||||||
write_string_prop(writer, "getcontenttype", "text/calendar;charset=utf-8")?;
|
write_string_prop(writer, "getcontenttype", "text/calendar;charset=utf-8")?;
|
||||||
}
|
}
|
||||||
_ => return Err(anyhow!("invalid prop!")),
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_dead_props() -> Vec<&'static str> {
|
|
||||||
vec!["getetag", "calendar-data", "getcontenttype"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use quick_xml::events::BytesText;
|
|||||||
use rustical_auth::AuthInfo;
|
use rustical_auth::AuthInfo;
|
||||||
use rustical_dav::{resource::Resource, xml_snippets::write_resourcetype};
|
use rustical_dav::{resource::Resource, xml_snippets::write_resourcetype};
|
||||||
use rustical_store::calendar::CalendarStore;
|
use rustical_store::calendar::CalendarStore;
|
||||||
|
use strum::{EnumString, IntoStaticStr, VariantNames};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use super::calendar::CalendarResource;
|
use super::calendar::CalendarResource;
|
||||||
@@ -19,10 +20,22 @@ pub struct PrincipalCalendarsResource<C: CalendarStore + ?Sized> {
|
|||||||
cal_store: Arc<RwLock<C>>,
|
cal_store: Arc<RwLock<C>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(EnumString, Debug, VariantNames, IntoStaticStr)]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
|
pub enum PrincipalProp {
|
||||||
|
Resourcetype,
|
||||||
|
CurrentUserPrincipal,
|
||||||
|
#[strum(serialize = "principal-URL")]
|
||||||
|
PrincipalUrl,
|
||||||
|
CalendarHomeSet,
|
||||||
|
CalendarUserAddressSet,
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl<C: CalendarStore + ?Sized> Resource for PrincipalCalendarsResource<C> {
|
impl<C: CalendarStore + ?Sized> Resource for PrincipalCalendarsResource<C> {
|
||||||
type UriComponents = ();
|
type UriComponents = ();
|
||||||
type MemberType = CalendarResource<C>;
|
type MemberType = CalendarResource<C>;
|
||||||
|
type PropType = PrincipalProp;
|
||||||
|
|
||||||
fn get_path(&self) -> &str {
|
fn get_path(&self) -> &str {
|
||||||
&self.path
|
&self.path
|
||||||
@@ -71,20 +84,23 @@ impl<C: CalendarStore + ?Sized> Resource for PrincipalCalendarsResource<C> {
|
|||||||
fn write_prop<W: std::io::Write>(
|
fn write_prop<W: std::io::Write>(
|
||||||
&self,
|
&self,
|
||||||
writer: &mut quick_xml::Writer<W>,
|
writer: &mut quick_xml::Writer<W>,
|
||||||
prop: &str,
|
prop: Self::PropType,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
match prop {
|
match prop {
|
||||||
"resourcetype" => write_resourcetype(writer, vec!["principal", "collection"])?,
|
PrincipalProp::Resourcetype => {
|
||||||
"current-user-principal" | "principal-URL" => {
|
write_resourcetype(writer, vec!["principal", "collection"])?
|
||||||
|
}
|
||||||
|
PrincipalProp::CurrentUserPrincipal | PrincipalProp::PrincipalUrl => {
|
||||||
write_href_prop(
|
write_href_prop(
|
||||||
writer,
|
writer,
|
||||||
prop,
|
prop.into(),
|
||||||
&format!("{}/{}/", self.prefix, self.principal),
|
&format!("{}/{}/", self.prefix, self.principal),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
"calendar-home-set" | "calendar-user-address-set" => {
|
PrincipalProp::CalendarHomeSet | PrincipalProp::CalendarUserAddressSet => {
|
||||||
|
let propname: &'static str = prop.into();
|
||||||
writer
|
writer
|
||||||
.create_element(&format!("C:{prop}"))
|
.create_element(&format!("C:{propname}"))
|
||||||
.write_inner_content(|writer| {
|
.write_inner_content(|writer| {
|
||||||
writer
|
writer
|
||||||
.create_element("href")
|
.create_element("href")
|
||||||
@@ -95,21 +111,7 @@ impl<C: CalendarStore + ?Sized> Resource for PrincipalCalendarsResource<C> {
|
|||||||
Ok::<(), quick_xml::Error>(())
|
Ok::<(), quick_xml::Error>(())
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
"allprops" => {}
|
|
||||||
_ => {
|
|
||||||
return Err(anyhow!("invalid prop"));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_dead_props() -> Vec<&'static str> {
|
|
||||||
vec![
|
|
||||||
"resourcetype",
|
|
||||||
"current-user-principal",
|
|
||||||
"principal-URL",
|
|
||||||
"calendar-home-set",
|
|
||||||
"calendar-user-address-set",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use async_trait::async_trait;
|
|||||||
use quick_xml::events::BytesText;
|
use quick_xml::events::BytesText;
|
||||||
use rustical_auth::AuthInfo;
|
use rustical_auth::AuthInfo;
|
||||||
use rustical_dav::{resource::Resource, xml_snippets::write_resourcetype};
|
use rustical_dav::{resource::Resource, xml_snippets::write_resourcetype};
|
||||||
|
use strum::{EnumString, VariantNames};
|
||||||
|
|
||||||
pub struct RootResource {
|
pub struct RootResource {
|
||||||
prefix: String,
|
prefix: String,
|
||||||
@@ -11,10 +12,18 @@ pub struct RootResource {
|
|||||||
path: String,
|
path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(EnumString, Debug, VariantNames)]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
|
pub enum RootProp {
|
||||||
|
Resourcetype,
|
||||||
|
CurrentUserPrincipal,
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl Resource for RootResource {
|
impl Resource for RootResource {
|
||||||
type UriComponents = ();
|
type UriComponents = ();
|
||||||
type MemberType = Self;
|
type MemberType = Self;
|
||||||
|
type PropType = RootProp;
|
||||||
|
|
||||||
fn get_path(&self) -> &str {
|
fn get_path(&self) -> &str {
|
||||||
&self.path
|
&self.path
|
||||||
@@ -40,11 +49,11 @@ impl Resource for RootResource {
|
|||||||
fn write_prop<W: std::io::Write>(
|
fn write_prop<W: std::io::Write>(
|
||||||
&self,
|
&self,
|
||||||
writer: &mut quick_xml::Writer<W>,
|
writer: &mut quick_xml::Writer<W>,
|
||||||
prop: &str,
|
prop: Self::PropType,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
match prop {
|
match prop {
|
||||||
"resourcetype" => write_resourcetype(writer, vec!["collection"])?,
|
RootProp::Resourcetype => write_resourcetype(writer, vec!["collection"])?,
|
||||||
"current-user-principal" => {
|
RootProp::CurrentUserPrincipal => {
|
||||||
writer
|
writer
|
||||||
.create_element("current-user-principal")
|
.create_element("current-user-principal")
|
||||||
.write_inner_content(|writer| {
|
.write_inner_content(|writer| {
|
||||||
@@ -57,12 +66,7 @@ impl Resource for RootResource {
|
|||||||
Ok::<(), quick_xml::Error>(())
|
Ok::<(), quick_xml::Error>(())
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
_ => return Err(anyhow!("invalid prop!")),
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_dead_props() -> Vec<&'static str> {
|
|
||||||
vec!["resourcetype", "current-user-principal"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,3 +11,4 @@ derive_more = "0.99"
|
|||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
quick-xml = "0.31"
|
quick-xml = "0.31"
|
||||||
rustical_auth = { path = "../auth/" }
|
rustical_auth = { path = "../auth/" }
|
||||||
|
strum = "0.26.2"
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
use std::io::Write;
|
use std::{io::Write, str::FromStr};
|
||||||
|
|
||||||
use actix_web::{http::StatusCode, HttpRequest};
|
use actix_web::{http::StatusCode, HttpRequest};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use quick_xml::Writer;
|
use quick_xml::Writer;
|
||||||
use rustical_auth::AuthInfo;
|
use rustical_auth::AuthInfo;
|
||||||
|
use strum::VariantNames;
|
||||||
|
|
||||||
use crate::xml_snippets::{write_invalid_props_response, write_propstat_response};
|
use crate::xml_snippets::{write_invalid_props_response, write_propstat_response};
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ use crate::xml_snippets::{write_invalid_props_response, write_propstat_response}
|
|||||||
pub trait Resource: Sized {
|
pub trait Resource: Sized {
|
||||||
type MemberType: Resource;
|
type MemberType: Resource;
|
||||||
type UriComponents: Sized; // defines how the resource URI maps to parameters, i.e. /{principal}/{calendar} -> (String, String)
|
type UriComponents: Sized; // defines how the resource URI maps to parameters, i.e. /{principal}/{calendar} -> (String, String)
|
||||||
|
type PropType: FromStr + VariantNames;
|
||||||
|
|
||||||
async fn acquire_from_request(
|
async fn acquire_from_request(
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
@@ -27,8 +29,10 @@ pub trait Resource: Sized {
|
|||||||
fn get_path(&self) -> &str;
|
fn get_path(&self) -> &str;
|
||||||
async fn get_members(&self) -> Result<Vec<Self::MemberType>>;
|
async fn get_members(&self) -> Result<Vec<Self::MemberType>>;
|
||||||
|
|
||||||
fn list_dead_props() -> Vec<&'static str>;
|
fn list_dead_props() -> &'static [&'static str] {
|
||||||
fn write_prop<W: Write>(&self, writer: &mut Writer<W>, prop: &str) -> Result<()>;
|
Self::PropType::VARIANTS
|
||||||
|
}
|
||||||
|
fn write_prop<W: Write>(&self, writer: &mut Writer<W>, prop: Self::PropType) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HandlePropfind {
|
pub trait HandlePropfind {
|
||||||
@@ -43,7 +47,7 @@ impl<R: Resource> HandlePropfind for R {
|
|||||||
// allprops MUST be the only queried prop per spec
|
// allprops MUST be the only queried prop per spec
|
||||||
return Err(anyhow!("allprops MUST be the only queried prop"));
|
return Err(anyhow!("allprops MUST be the only queried prop"));
|
||||||
}
|
}
|
||||||
props = R::list_dead_props();
|
props = R::list_dead_props().into();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut invalid_props = Vec::<&str>::new();
|
let mut invalid_props = Vec::<&str>::new();
|
||||||
@@ -53,14 +57,20 @@ impl<R: Resource> HandlePropfind for R {
|
|||||||
|
|
||||||
write_propstat_response(&mut writer, self.get_path(), StatusCode::OK, |writer| {
|
write_propstat_response(&mut writer, self.get_path(), StatusCode::OK, |writer| {
|
||||||
for prop in props {
|
for prop in props {
|
||||||
|
if let Ok(valid_prop) = R::PropType::from_str(prop) {
|
||||||
// TODO: Fix error types
|
// TODO: Fix error types
|
||||||
match self
|
match self
|
||||||
.write_prop(writer, prop)
|
.write_prop(writer, valid_prop)
|
||||||
.map_err(|_e| quick_xml::Error::TextNotFound)
|
.map_err(|_e| quick_xml::Error::TextNotFound)
|
||||||
{
|
{
|
||||||
|
// TODO: clean this mess up
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
|
// not really an invalid prop, but some error happened
|
||||||
Err(_) => invalid_props.push(prop),
|
Err(_) => invalid_props.push(prop),
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
invalid_props.push(prop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
Reference in New Issue
Block a user