mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 10:32:19 +00:00
dav: Make reusable for other projects
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use crate::{
|
||||
Principal,
|
||||
privileges::UserPrivilegeSet,
|
||||
resource::{NamedRoute, Resource},
|
||||
xml::{HrefElement, Resourcetype},
|
||||
};
|
||||
use actix_web::dev::ResourceMap;
|
||||
use rustical_store::auth::User;
|
||||
use rustical_xml::{EnumUnitVariants, EnumVariants, XmlDeserialize, XmlSerialize};
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumUnitVariants, EnumVariants)]
|
||||
@@ -31,7 +31,7 @@ pub trait CommonPropertiesExtension: Resource {
|
||||
fn get_prop(
|
||||
&self,
|
||||
rmap: &ResourceMap,
|
||||
user: &User,
|
||||
principal: &Self::Principal,
|
||||
prop: &CommonPropertiesPropName,
|
||||
) -> Result<CommonPropertiesProp, <Self as Resource>::Error> {
|
||||
Ok(match prop {
|
||||
@@ -40,13 +40,13 @@ pub trait CommonPropertiesExtension: Resource {
|
||||
}
|
||||
CommonPropertiesPropName::CurrentUserPrincipal => {
|
||||
CommonPropertiesProp::CurrentUserPrincipal(
|
||||
Self::PrincipalResource::get_url(rmap, [&user.id])
|
||||
Self::PrincipalResource::get_url(rmap, [&principal.get_id()])
|
||||
.unwrap()
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
CommonPropertiesPropName::CurrentUserPrivilegeSet => {
|
||||
CommonPropertiesProp::CurrentUserPrivilegeSet(self.get_user_privileges(user)?)
|
||||
CommonPropertiesProp::CurrentUserPrivilegeSet(self.get_user_privileges(principal)?)
|
||||
}
|
||||
CommonPropertiesPropName::Owner => {
|
||||
CommonPropertiesProp::Owner(self.get_owner().map(|owner| {
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
use crate::push::Transports;
|
||||
use rustical_xml::{EnumUnitVariants, EnumVariants, XmlDeserialize, XmlSerialize};
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, EnumUnitVariants, EnumVariants)]
|
||||
#[xml(unit_variants_ident = "DavPushExtensionPropName")]
|
||||
pub enum DavPushExtensionProp {
|
||||
// WebDav Push
|
||||
#[xml(skip_deserializing)]
|
||||
#[xml(ns = "crate::namespace::NS_DAVPUSH")]
|
||||
Transports(Transports),
|
||||
#[xml(ns = "crate::namespace::NS_DAVPUSH")]
|
||||
Topic(String),
|
||||
}
|
||||
|
||||
pub trait DavPushExtension {
|
||||
fn get_topic(&self) -> String;
|
||||
|
||||
fn get_prop(
|
||||
&self,
|
||||
prop: &DavPushExtensionPropName,
|
||||
) -> Result<DavPushExtensionProp, crate::Error> {
|
||||
Ok(match &prop {
|
||||
DavPushExtensionPropName::Transports => {
|
||||
DavPushExtensionProp::Transports(Default::default())
|
||||
}
|
||||
DavPushExtensionPropName::Topic => DavPushExtensionProp::Topic(self.get_topic()),
|
||||
})
|
||||
}
|
||||
|
||||
fn set_prop(&self, _prop: DavPushExtensionProp) -> Result<(), crate::Error> {
|
||||
Err(crate::Error::PropReadOnly)
|
||||
}
|
||||
|
||||
fn remove_prop(&self, _prop: &DavPushExtensionPropName) -> Result<(), crate::Error> {
|
||||
Err(crate::Error::PropReadOnly)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
mod common;
|
||||
mod davpush;
|
||||
mod synctoken;
|
||||
|
||||
pub use common::*;
|
||||
pub use davpush::*;
|
||||
pub use synctoken::*;
|
||||
|
||||
Reference in New Issue
Block a user