mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 09:22:26 +00:00
Refactoring around routing and getting the principal uri (less dependence on actix)
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
use crate::{Error, principal::PrincipalResource};
|
||||
use actix_web::dev::ResourceMap;
|
||||
use crate::{CardDavPrincipalUri, Error};
|
||||
use async_trait::async_trait;
|
||||
use derive_more::derive::{Constructor, From, Into};
|
||||
use rustical_dav::{
|
||||
extensions::{CommonPropertiesExtension, CommonPropertiesProp},
|
||||
privileges::UserPrivilegeSet,
|
||||
resource::{Resource, ResourceService},
|
||||
resource::{PrincipalUri, Resource, ResourceService},
|
||||
xml::Resourcetype,
|
||||
};
|
||||
use rustical_store::{AddressObject, AddressbookStore, auth::User};
|
||||
@@ -47,10 +46,6 @@ pub struct AddressObjectResource {
|
||||
pub principal: String,
|
||||
}
|
||||
|
||||
impl CommonPropertiesExtension for AddressObjectResource {
|
||||
type PrincipalResource = PrincipalResource;
|
||||
}
|
||||
|
||||
impl Resource for AddressObjectResource {
|
||||
type Prop = AddressObjectPropWrapper;
|
||||
type Error = Error;
|
||||
@@ -62,7 +57,7 @@ impl Resource for AddressObjectResource {
|
||||
|
||||
fn get_prop(
|
||||
&self,
|
||||
rmap: &ResourceMap,
|
||||
puri: &impl PrincipalUri,
|
||||
user: &User,
|
||||
prop: &AddressObjectPropWrapperName,
|
||||
) -> Result<Self::Prop, Self::Error> {
|
||||
@@ -81,7 +76,7 @@ impl Resource for AddressObjectResource {
|
||||
})
|
||||
}
|
||||
AddressObjectPropWrapperName::Common(prop) => AddressObjectPropWrapper::Common(
|
||||
CommonPropertiesExtension::get_prop(self, rmap, user, prop)?,
|
||||
CommonPropertiesExtension::get_prop(self, puri, user, prop)?,
|
||||
),
|
||||
})
|
||||
}
|
||||
@@ -115,6 +110,7 @@ impl<AS: AddressbookStore> ResourceService for AddressObjectResourceService<AS>
|
||||
type MemberType = AddressObjectResource;
|
||||
type Error = Error;
|
||||
type Principal = User;
|
||||
type PrincipalUri = CardDavPrincipalUri;
|
||||
|
||||
async fn get_resource(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user