Refactoring around routing and getting the principal uri (less dependence on actix)

This commit is contained in:
Lennart K
2025-06-02 16:17:13 +02:00
parent 0f294cf2e1
commit ef33868151
23 changed files with 169 additions and 216 deletions

View File

@@ -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,