birthday calendar, lots of refactoring

This commit is contained in:
Lennart
2025-01-12 16:04:38 +01:00
parent f031478786
commit b9af6c10a3
19 changed files with 284 additions and 210 deletions

View File

@@ -3,7 +3,7 @@ use crate::Error;
use actix_web::dev::ResourceMap;
use async_trait::async_trait;
use rustical_dav::privileges::UserPrivilegeSet;
use rustical_dav::resource::{Resource, ResourceService};
use rustical_dav::resource::{NamedRoute, Resource, ResourceService};
use rustical_dav::xml::{HrefElement, Resourcetype, ResourcetypeInner};
use rustical_store::auth::User;
use rustical_store::AddressbookStore;
@@ -52,6 +52,12 @@ impl PrincipalResource {
}
}
impl NamedRoute for PrincipalResource {
fn route_name() -> &'static str {
"carddav_principal"
}
}
impl Resource for PrincipalResource {
type PropName = PrincipalPropName;
type Prop = PrincipalProp;
@@ -82,11 +88,6 @@ impl Resource for PrincipalResource {
})
}
#[inline]
fn resource_name() -> &'static str {
"carddav_principal"
}
fn get_owner(&self) -> Option<&str> {
Some(&self.principal)
}
@@ -115,17 +116,11 @@ impl<A: AddressbookStore + ?Sized> ResourceService for PrincipalResourceService<
async fn get_members(
&self,
(principal,): &Self::PathComponents,
rmap: &ResourceMap,
) -> Result<Vec<(String, Self::MemberType)>, Self::Error> {
let addressbooks = self.addr_store.get_addressbooks(principal).await?;
Ok(addressbooks
.into_iter()
.map(|addressbook| {
(
AddressbookResource::get_url(rmap, vec![principal, &addressbook.id]).unwrap(),
addressbook.into(),
)
})
.map(|addressbook| (addressbook.id.to_owned(), addressbook.into()))
.collect())
}
}