fix some dumb design decisions

This commit is contained in:
Lennart
2024-11-04 17:57:09 +01:00
parent 0fed7b05fa
commit c41e3e3abb
9 changed files with 17 additions and 72 deletions

View File

@@ -14,9 +14,7 @@ use actix_web::{web::Data, HttpRequest};
use async_trait::async_trait;
use derive_more::derive::{From, Into, TryInto};
use rustical_dav::extension::BoxedExtension;
use rustical_dav::extensions::{
CommonPropertiesExtension, CommonPropertiesProp, CommonPropertiesPropName,
};
use rustical_dav::extensions::{CommonPropertiesExtension, CommonPropertiesProp};
use rustical_dav::privileges::UserPrivilegeSet;
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
use rustical_store::auth::User;
@@ -33,7 +31,7 @@ pub struct CalendarResourceService<C: CalendarStore + ?Sized> {
pub calendar_id: String,
}
#[derive(EnumString, VariantNames, Clone, From, TryInto)]
#[derive(EnumString, VariantNames, Clone)]
#[strum(serialize_all = "kebab-case")]
pub enum CalendarPropName {
Displayname,
@@ -48,10 +46,6 @@ pub enum CalendarPropName {
SupportedReportSet,
SyncToken,
Getctag,
#[from]
#[try_into]
#[strum(disabled)]
ExtCommonProperties(CommonPropertiesPropName),
}
#[derive(Deserialize, Serialize, From, TryInto)]
@@ -157,15 +151,11 @@ impl Resource for CalendarResource {
CalendarProp::Getcontenttype("text/calendar;charset=utf-8".to_owned())
}
CalendarPropName::MaxResourceSize => CalendarProp::MaxResourceSize(10000000),
// CalendarPropName::CurrentUserPrivilegeSet => {
// CalendarProp::CurrentUserPrivilegeSet(user_privileges.to_owned())
// }
CalendarPropName::SupportedReportSet => {
CalendarProp::SupportedReportSet(SupportedReportSet::default())
}
CalendarPropName::SyncToken => CalendarProp::SyncToken(self.0.format_synctoken()),
CalendarPropName::Getctag => CalendarProp::Getctag(self.0.format_synctoken()),
_ => panic!("we shouldn't end up here"),
})
}
@@ -197,7 +187,6 @@ impl Resource for CalendarResource {
CalendarProp::SupportedCalendarData(_) => Err(rustical_dav::Error::PropReadOnly),
CalendarProp::Getcontenttype(_) => Err(rustical_dav::Error::PropReadOnly),
CalendarProp::MaxResourceSize(_) => Err(rustical_dav::Error::PropReadOnly),
// CalendarProp::CurrentUserPrivilegeSet(_) => Err(rustical_dav::Error::PropReadOnly),
CalendarProp::SupportedReportSet(_) => Err(rustical_dav::Error::PropReadOnly),
CalendarProp::SyncToken(_) => Err(rustical_dav::Error::PropReadOnly),
CalendarProp::Getctag(_) => Err(rustical_dav::Error::PropReadOnly),
@@ -234,11 +223,9 @@ impl Resource for CalendarResource {
CalendarPropName::SupportedCalendarData => Err(rustical_dav::Error::PropReadOnly),
CalendarPropName::Getcontenttype => Err(rustical_dav::Error::PropReadOnly),
CalendarPropName::MaxResourceSize => Err(rustical_dav::Error::PropReadOnly),
// CalendarPropName::CurrentUserPrivilegeSet => Err(rustical_dav::Error::PropReadOnly),
CalendarPropName::SupportedReportSet => Err(rustical_dav::Error::PropReadOnly),
CalendarPropName::SyncToken => Err(rustical_dav::Error::PropReadOnly),
CalendarPropName::Getctag => Err(rustical_dav::Error::PropReadOnly),
_ => panic!("we shouldn't end up here"),
}
}

View File

@@ -5,7 +5,7 @@ use async_trait::async_trait;
use derive_more::derive::{From, Into, TryInto};
use rustical_dav::{
extension::BoxedExtension,
extensions::{CommonPropertiesExtension, CommonPropertiesProp, CommonPropertiesPropName},
extensions::{CommonPropertiesExtension, CommonPropertiesProp},
privileges::UserPrivilegeSet,
resource::{InvalidProperty, Resource, ResourceService},
};
@@ -22,16 +22,12 @@ pub struct CalendarObjectResourceService<C: CalendarStore + ?Sized> {
pub object_id: String,
}
#[derive(EnumString, VariantNames, Clone, From, TryInto)]
#[derive(EnumString, VariantNames, Clone)]
#[strum(serialize_all = "kebab-case")]
pub enum CalendarObjectPropName {
Getetag,
CalendarData,
Getcontenttype,
#[from]
#[try_into]
#[strum(disabled)]
ExtCommonProperties(CommonPropertiesPropName),
}
#[derive(Deserialize, Serialize, From, TryInto)]
@@ -99,7 +95,6 @@ impl Resource for CalendarObjectResource {
CalendarObjectPropName::Getcontenttype => {
CalendarObjectProp::Getcontenttype("text/calendar;charset=utf-8".to_owned())
}
_ => panic!("we shouldn't end up here"),
})
}

View File

@@ -6,9 +6,7 @@ use actix_web::HttpRequest;
use async_trait::async_trait;
use derive_more::derive::{From, TryInto};
use rustical_dav::extension::BoxedExtension;
use rustical_dav::extensions::{
CommonPropertiesExtension, CommonPropertiesProp, CommonPropertiesPropName,
};
use rustical_dav::extensions::{CommonPropertiesExtension, CommonPropertiesProp};
use rustical_dav::privileges::UserPrivilegeSet;
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
use rustical_dav::xml::HrefElement;
@@ -63,17 +61,13 @@ impl InvalidProperty for PrincipalProp {
}
}
#[derive(EnumString, VariantNames, Clone, From, TryInto)]
#[derive(EnumString, VariantNames, Clone)]
#[strum(serialize_all = "kebab-case")]
pub enum PrincipalPropName {
#[strum(serialize = "principal-URL")]
PrincipalUrl,
CalendarHomeSet,
CalendarUserAddressSet,
#[from]
#[try_into]
#[strum(disabled)]
ExtCommonProperties(CommonPropertiesPropName),
}
impl PrincipalResource {
@@ -108,7 +102,6 @@ impl Resource for PrincipalResource {
PrincipalPropName::CalendarUserAddressSet => {
PrincipalProp::CalendarUserAddressSet(principal_href)
}
_ => panic!("we shouldn't end up here"),
})
}