mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
birthday calendar, lots of refactoring
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user