mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 15:52:27 +00:00
Remove all that extension business and replace with internal properties
This commit is contained in:
@@ -10,7 +10,7 @@ use actix_web::{
|
||||
};
|
||||
use rustical_dav::{
|
||||
methods::propfind::{PropElement, PropfindType},
|
||||
resource::Resource,
|
||||
resource::{CommonPropertiesProp, EitherProp, Resource},
|
||||
xml::{
|
||||
multistatus::{PropstatWrapper, ResponseElement},
|
||||
MultistatusElement,
|
||||
@@ -69,7 +69,13 @@ pub async fn handle_calendar_multiget<C: CalendarStore + ?Sized>(
|
||||
principal: &str,
|
||||
cal_id: &str,
|
||||
cal_store: &C,
|
||||
) -> Result<MultistatusElement<PropstatWrapper<CalendarObjectProp>, String>, Error> {
|
||||
) -> Result<
|
||||
MultistatusElement<
|
||||
PropstatWrapper<EitherProp<CalendarObjectProp, CommonPropertiesProp>>,
|
||||
String,
|
||||
>,
|
||||
Error,
|
||||
> {
|
||||
let principal_url = PrincipalResource::get_url(req.resource_map(), vec![principal]).unwrap();
|
||||
let (objects, not_found) =
|
||||
get_objects_calendar_multiget(&cal_multiget, &principal_url, principal, cal_id, cal_store)
|
||||
|
||||
@@ -2,7 +2,7 @@ use actix_web::HttpRequest;
|
||||
use chrono::{DateTime, Utc};
|
||||
use rustical_dav::{
|
||||
methods::propfind::{PropElement, PropfindType},
|
||||
resource::Resource,
|
||||
resource::{CommonPropertiesProp, EitherProp, Resource},
|
||||
xml::{multistatus::PropstatWrapper, MultistatusElement},
|
||||
};
|
||||
use rustical_store::{auth::User, CalendarObject, CalendarStore};
|
||||
@@ -210,7 +210,13 @@ pub async fn handle_calendar_query<C: CalendarStore + ?Sized>(
|
||||
principal: &str,
|
||||
cal_id: &str,
|
||||
cal_store: &C,
|
||||
) -> Result<MultistatusElement<PropstatWrapper<CalendarObjectProp>, String>, Error> {
|
||||
) -> Result<
|
||||
MultistatusElement<
|
||||
PropstatWrapper<EitherProp<CalendarObjectProp, CommonPropertiesProp>>,
|
||||
String,
|
||||
>,
|
||||
Error,
|
||||
> {
|
||||
let objects = get_objects_calendar_query(&cal_query, principal, cal_id, cal_store).await?;
|
||||
|
||||
let props = match cal_query.prop {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use actix_web::{http::StatusCode, HttpRequest};
|
||||
use rustical_dav::{
|
||||
methods::propfind::{PropElement, PropfindType},
|
||||
resource::Resource,
|
||||
resource::{CommonPropertiesProp, EitherProp, Resource},
|
||||
xml::{
|
||||
multistatus::{PropstatWrapper, ResponseElement},
|
||||
MultistatusElement,
|
||||
@@ -49,7 +49,13 @@ pub async fn handle_sync_collection<C: CalendarStore + ?Sized>(
|
||||
principal: &str,
|
||||
cal_id: &str,
|
||||
cal_store: &C,
|
||||
) -> Result<MultistatusElement<PropstatWrapper<CalendarObjectProp>, String>, Error> {
|
||||
) -> Result<
|
||||
MultistatusElement<
|
||||
PropstatWrapper<EitherProp<CalendarObjectProp, CommonPropertiesProp>>,
|
||||
String,
|
||||
>,
|
||||
Error,
|
||||
> {
|
||||
let props = match sync_collection.prop {
|
||||
PropfindType::Allprop => {
|
||||
vec!["allprop".to_owned()]
|
||||
|
||||
@@ -13,7 +13,6 @@ use actix_web::web;
|
||||
use actix_web::{web::Data, HttpRequest};
|
||||
use async_trait::async_trait;
|
||||
use derive_more::derive::{From, Into};
|
||||
use rustical_dav::extensions::CommonPropertiesProp;
|
||||
use rustical_dav::privileges::UserPrivilegeSet;
|
||||
use rustical_dav::resource::{Resource, ResourceService};
|
||||
use rustical_store::auth::User;
|
||||
@@ -46,7 +45,7 @@ pub enum CalendarPropName {
|
||||
Getctag,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||
#[derive(Default, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum CalendarProp {
|
||||
// WebDAV (RFC 2518)
|
||||
@@ -83,10 +82,6 @@ pub enum CalendarProp {
|
||||
// Didn't find the spec
|
||||
Getctag(String),
|
||||
|
||||
#[serde(skip_deserializing, rename = "$value")]
|
||||
#[from]
|
||||
ExtCommonProperties(CommonPropertiesProp),
|
||||
|
||||
#[serde(other)]
|
||||
#[default]
|
||||
Invalid,
|
||||
@@ -183,7 +178,6 @@ impl Resource for CalendarResource {
|
||||
CalendarProp::SyncToken(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarProp::Getctag(_) => Err(rustical_dav::Error::PropReadOnly),
|
||||
CalendarProp::Invalid => Err(rustical_dav::Error::PropReadOnly),
|
||||
_ => panic!("we shouldn't end up here"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ use actix_web::{dev::ResourceMap, web::Data, HttpRequest};
|
||||
use async_trait::async_trait;
|
||||
use derive_more::derive::{From, Into};
|
||||
use rustical_dav::{
|
||||
extensions::CommonPropertiesProp,
|
||||
privileges::UserPrivilegeSet,
|
||||
resource::{Resource, ResourceService},
|
||||
};
|
||||
@@ -28,7 +27,7 @@ pub enum CalendarObjectPropName {
|
||||
Getcontenttype,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||
#[derive(Default, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum CalendarObjectProp {
|
||||
// WebDAV (RFC 2518)
|
||||
@@ -39,10 +38,6 @@ pub enum CalendarObjectProp {
|
||||
#[serde(rename = "C:calendar-data")]
|
||||
CalendarData(String),
|
||||
|
||||
#[serde(skip_deserializing, rename = "$value")]
|
||||
#[from]
|
||||
ExtCommonProperties(CommonPropertiesProp),
|
||||
|
||||
#[serde(other)]
|
||||
#[default]
|
||||
Invalid,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use actix_web::{http::StatusCode, HttpResponse};
|
||||
use tracing::error;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
@@ -41,6 +42,7 @@ impl actix_web::ResponseError for Error {
|
||||
}
|
||||
}
|
||||
fn error_response(&self) -> actix_web::HttpResponse<actix_web::body::BoxBody> {
|
||||
error!("Error: {self}");
|
||||
match self {
|
||||
Error::DavError(err) => err.error_response(),
|
||||
_ => HttpResponse::build(self.status_code()).body(self.to_string()),
|
||||
|
||||
@@ -4,8 +4,6 @@ use actix_web::dev::ResourceMap;
|
||||
use actix_web::web::Data;
|
||||
use actix_web::HttpRequest;
|
||||
use async_trait::async_trait;
|
||||
use derive_more::derive::From;
|
||||
use rustical_dav::extensions::CommonPropertiesProp;
|
||||
use rustical_dav::privileges::UserPrivilegeSet;
|
||||
use rustical_dav::resource::{Resource, ResourceService};
|
||||
use rustical_dav::xml::HrefElement;
|
||||
@@ -25,7 +23,7 @@ pub struct PrincipalResource {
|
||||
principal: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize, Serialize, From, PartialEq)]
|
||||
#[derive(Default, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum PrincipalProp {
|
||||
// WebDAV Access Control (RFC 3744)
|
||||
@@ -38,10 +36,6 @@ pub enum PrincipalProp {
|
||||
#[serde(rename = "C:calendar-user-address-set")]
|
||||
CalendarUserAddressSet(HrefElement),
|
||||
|
||||
#[serde(skip_deserializing, rename = "$value")]
|
||||
#[from]
|
||||
ExtCommonProperties(CommonPropertiesProp),
|
||||
|
||||
#[serde(other)]
|
||||
#[default]
|
||||
Invalid,
|
||||
|
||||
Reference in New Issue
Block a user