mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
stores: Switch from dyn to impl and implement Sized
This commit is contained in:
@@ -41,7 +41,7 @@ struct MkcalendarRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
||||||
pub async fn route_mkcalendar<C: CalendarStore + ?Sized>(
|
pub async fn route_mkcalendar<C: CalendarStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
body: String,
|
body: String,
|
||||||
user: User,
|
user: User,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use tracing::instrument;
|
|||||||
use tracing_actix_web::RootSpan;
|
use tracing_actix_web::RootSpan;
|
||||||
|
|
||||||
#[instrument(parent = root_span.id(), skip(store, subscription_store, root_span, req))]
|
#[instrument(parent = root_span.id(), skip(store, subscription_store, root_span, req))]
|
||||||
pub async fn route_post<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized>(
|
pub async fn route_post<C: CalendarStore, S: SubscriptionStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
body: String,
|
body: String,
|
||||||
user: User,
|
user: User,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub(crate) struct CalendarMultigetRequest {
|
|||||||
pub(crate) href: Vec<String>,
|
pub(crate) href: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_objects_calendar_multiget<C: CalendarStore + ?Sized>(
|
pub async fn get_objects_calendar_multiget<C: CalendarStore>(
|
||||||
cal_query: &CalendarMultigetRequest,
|
cal_query: &CalendarMultigetRequest,
|
||||||
path: &str,
|
path: &str,
|
||||||
principal: &str,
|
principal: &str,
|
||||||
@@ -52,7 +52,7 @@ pub async fn get_objects_calendar_multiget<C: CalendarStore + ?Sized>(
|
|||||||
Ok((result, not_found))
|
Ok((result, not_found))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_calendar_multiget<C: CalendarStore + ?Sized>(
|
pub async fn handle_calendar_multiget<C: CalendarStore>(
|
||||||
cal_multiget: CalendarMultigetRequest,
|
cal_multiget: CalendarMultigetRequest,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
user: &User,
|
user: &User,
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ pub struct CalendarQueryRequest {
|
|||||||
pub(crate) timezone_id: Option<String>,
|
pub(crate) timezone_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_objects_calendar_query<C: CalendarStore + ?Sized>(
|
pub async fn get_objects_calendar_query<C: CalendarStore>(
|
||||||
cal_query: &CalendarQueryRequest,
|
cal_query: &CalendarQueryRequest,
|
||||||
principal: &str,
|
principal: &str,
|
||||||
cal_id: &str,
|
cal_id: &str,
|
||||||
@@ -188,7 +188,7 @@ pub async fn get_objects_calendar_query<C: CalendarStore + ?Sized>(
|
|||||||
Ok(objects)
|
Ok(objects)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_calendar_query<C: CalendarStore + ?Sized>(
|
pub async fn handle_calendar_query<C: CalendarStore>(
|
||||||
cal_query: CalendarQueryRequest,
|
cal_query: CalendarQueryRequest,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
user: &User,
|
user: &User,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub(crate) enum ReportRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(req, cal_store))]
|
#[instrument(skip(req, cal_store))]
|
||||||
pub async fn route_report_calendar<C: CalendarStore + ?Sized>(
|
pub async fn route_report_calendar<C: CalendarStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
body: String,
|
body: String,
|
||||||
user: User,
|
user: User,
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ pub(crate) struct SyncCollectionRequest {
|
|||||||
pub(crate) limit: Option<u64>,
|
pub(crate) limit: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_sync_collection<C: CalendarStore + ?Sized>(
|
pub async fn handle_sync_collection<C: CalendarStore>(
|
||||||
sync_collection: SyncCollectionRequest,
|
sync_collection: SyncCollectionRequest,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
user: &User,
|
user: &User,
|
||||||
|
|||||||
@@ -255,12 +255,12 @@ impl Resource for CalendarResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CalendarResourceService<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized> {
|
pub struct CalendarResourceService<C: CalendarStore, S: SubscriptionStore> {
|
||||||
cal_store: Arc<C>,
|
cal_store: Arc<C>,
|
||||||
__phantom_sub: PhantomData<S>,
|
__phantom_sub: PhantomData<S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized> CalendarResourceService<C, S> {
|
impl<C: CalendarStore, S: SubscriptionStore> CalendarResourceService<C, S> {
|
||||||
pub fn new(cal_store: Arc<C>) -> Self {
|
pub fn new(cal_store: Arc<C>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cal_store,
|
cal_store,
|
||||||
@@ -270,7 +270,7 @@ impl<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized> CalendarResourceS
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized> ResourceService
|
impl<C: CalendarStore, S: SubscriptionStore> ResourceService
|
||||||
for CalendarResourceService<C, S>
|
for CalendarResourceService<C, S>
|
||||||
{
|
{
|
||||||
type MemberType = CalendarObjectResource;
|
type MemberType = CalendarObjectResource;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use tracing_actix_web::RootSpan;
|
|||||||
use super::resource::CalendarObjectPathComponents;
|
use super::resource::CalendarObjectPathComponents;
|
||||||
|
|
||||||
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
||||||
pub async fn get_event<C: CalendarStore + ?Sized>(
|
pub async fn get_event<C: CalendarStore>(
|
||||||
path: Path<CalendarObjectPathComponents>,
|
path: Path<CalendarObjectPathComponents>,
|
||||||
store: Data<C>,
|
store: Data<C>,
|
||||||
user: User,
|
user: User,
|
||||||
@@ -42,7 +42,7 @@ pub async fn get_event<C: CalendarStore + ?Sized>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(parent = root_span.id(), skip(store, req, root_span))]
|
#[instrument(parent = root_span.id(), skip(store, req, root_span))]
|
||||||
pub async fn put_event<C: CalendarStore + ?Sized>(
|
pub async fn put_event<C: CalendarStore>(
|
||||||
path: Path<CalendarObjectPathComponents>,
|
path: Path<CalendarObjectPathComponents>,
|
||||||
store: Data<C>,
|
store: Data<C>,
|
||||||
body: String,
|
body: String,
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ use serde::Deserialize;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
||||||
|
|
||||||
pub struct CalendarObjectResourceService<C: CalendarStore + ?Sized> {
|
pub struct CalendarObjectResourceService<C: CalendarStore> {
|
||||||
cal_store: Arc<C>,
|
cal_store: Arc<C>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalendarStore + ?Sized> CalendarObjectResourceService<C> {
|
impl<C: CalendarStore> CalendarObjectResourceService<C> {
|
||||||
pub fn new(cal_store: Arc<C>) -> Self {
|
pub fn new(cal_store: Arc<C>) -> Self {
|
||||||
Self { cal_store }
|
Self { cal_store }
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ impl<'de> Deserialize<'de> for CalendarObjectPathComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl<C: CalendarStore + ?Sized> ResourceService for CalendarObjectResourceService<C> {
|
impl<C: CalendarStore> ResourceService for CalendarObjectResourceService<C> {
|
||||||
type PathComponents = CalendarObjectPathComponents;
|
type PathComponents = CalendarObjectPathComponents;
|
||||||
type Resource = CalendarObjectResource;
|
type Resource = CalendarObjectResource;
|
||||||
type MemberType = CalendarObjectResource;
|
type MemberType = CalendarObjectResource;
|
||||||
|
|||||||
@@ -67,18 +67,18 @@ impl Resource for CalendarSetResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CalendarSetResourceService<C: CalendarStore + ?Sized> {
|
pub struct CalendarSetResourceService<C: CalendarStore> {
|
||||||
cal_store: Arc<C>,
|
cal_store: Arc<C>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: CalendarStore + ?Sized> CalendarSetResourceService<C> {
|
impl<C: CalendarStore> CalendarSetResourceService<C> {
|
||||||
pub fn new(cal_store: Arc<C>) -> Self {
|
pub fn new(cal_store: Arc<C>) -> Self {
|
||||||
Self { cal_store }
|
Self { cal_store }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl<C: CalendarStore + ?Sized> ResourceService for CalendarSetResourceService<C> {
|
impl<C: CalendarStore> ResourceService for CalendarSetResourceService<C> {
|
||||||
type PathComponents = (String,);
|
type PathComponents = (String,);
|
||||||
type MemberType = CalendarResource;
|
type MemberType = CalendarResource;
|
||||||
type Resource = CalendarSetResource;
|
type Resource = CalendarSetResource;
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ pub fn configure_well_known(cfg: &mut web::ServiceConfig, caldav_root: String) {
|
|||||||
|
|
||||||
pub fn configure_dav<
|
pub fn configure_dav<
|
||||||
AP: AuthenticationProvider,
|
AP: AuthenticationProvider,
|
||||||
AS: AddressbookStore + ?Sized,
|
AS: AddressbookStore,
|
||||||
C: CalendarStore + ?Sized,
|
C: CalendarStore,
|
||||||
S: SubscriptionStore + ?Sized,
|
S: SubscriptionStore,
|
||||||
>(
|
>(
|
||||||
cfg: &mut web::ServiceConfig,
|
cfg: &mut web::ServiceConfig,
|
||||||
auth_provider: Arc<AP>,
|
auth_provider: Arc<AP>,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use rustical_xml::{XmlRootTag, XmlSerialize};
|
|||||||
|
|
||||||
use crate::calendar::resource::CalendarProp;
|
use crate::calendar::resource::CalendarProp;
|
||||||
|
|
||||||
async fn handle_delete<S: SubscriptionStore + ?Sized>(
|
async fn handle_delete<S: SubscriptionStore>(
|
||||||
store: Data<S>,
|
store: Data<S>,
|
||||||
path: Path<String>,
|
path: Path<String>,
|
||||||
) -> Result<HttpResponse, rustical_store::Error> {
|
) -> Result<HttpResponse, rustical_store::Error> {
|
||||||
@@ -17,7 +17,7 @@ async fn handle_delete<S: SubscriptionStore + ?Sized>(
|
|||||||
Ok(HttpResponse::NoContent().body("Unregistered"))
|
Ok(HttpResponse::NoContent().body("Unregistered"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn subscription_resource<S: SubscriptionStore + ?Sized>() -> actix_web::Resource {
|
pub fn subscription_resource<S: SubscriptionStore>() -> actix_web::Resource {
|
||||||
web::resource("/subscription/{id}")
|
web::resource("/subscription/{id}")
|
||||||
.name("subscription")
|
.name("subscription")
|
||||||
.delete(handle_delete::<S>)
|
.delete(handle_delete::<S>)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use tracing::instrument;
|
|||||||
use tracing_actix_web::RootSpan;
|
use tracing_actix_web::RootSpan;
|
||||||
|
|
||||||
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
||||||
pub async fn get_object<AS: AddressbookStore + ?Sized>(
|
pub async fn get_object<AS: AddressbookStore>(
|
||||||
path: Path<AddressObjectPathComponents>,
|
path: Path<AddressObjectPathComponents>,
|
||||||
store: Data<AS>,
|
store: Data<AS>,
|
||||||
user: User,
|
user: User,
|
||||||
@@ -43,7 +43,7 @@ pub async fn get_object<AS: AddressbookStore + ?Sized>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(parent = root_span.id(), skip(store, req, root_span))]
|
#[instrument(parent = root_span.id(), skip(store, req, root_span))]
|
||||||
pub async fn put_object<AS: AddressbookStore + ?Sized>(
|
pub async fn put_object<AS: AddressbookStore>(
|
||||||
path: Path<AddressObjectPathComponents>,
|
path: Path<AddressObjectPathComponents>,
|
||||||
store: Data<AS>,
|
store: Data<AS>,
|
||||||
body: String,
|
body: String,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::{principal::PrincipalResource, Error};
|
use crate::{principal::PrincipalResource, Error};
|
||||||
use actix_web::dev::ResourceMap;
|
use actix_web::dev::ResourceMap;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{Constructor, From, Into};
|
||||||
use rustical_dav::{
|
use rustical_dav::{
|
||||||
privileges::UserPrivilegeSet,
|
privileges::UserPrivilegeSet,
|
||||||
resource::{Resource, ResourceService},
|
resource::{Resource, ResourceService},
|
||||||
@@ -15,16 +15,11 @@ use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
|||||||
|
|
||||||
use super::methods::{get_object, put_object};
|
use super::methods::{get_object, put_object};
|
||||||
|
|
||||||
pub struct AddressObjectResourceService<AS: AddressbookStore + ?Sized> {
|
#[derive(Constructor)]
|
||||||
|
pub struct AddressObjectResourceService<AS: AddressbookStore> {
|
||||||
addr_store: Arc<AS>,
|
addr_store: Arc<AS>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: AddressbookStore + ?Sized> AddressObjectResourceService<A> {
|
|
||||||
pub fn new(addr_store: Arc<A>) -> Self {
|
|
||||||
Self { addr_store }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, EnumDiscriminants, Clone)]
|
#[derive(XmlDeserialize, XmlSerialize, PartialEq, EnumDiscriminants, Clone)]
|
||||||
#[strum_discriminants(
|
#[strum_discriminants(
|
||||||
name(AddressObjectPropName),
|
name(AddressObjectPropName),
|
||||||
@@ -111,7 +106,7 @@ impl<'de> Deserialize<'de> for AddressObjectPathComponents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl<AS: AddressbookStore + ?Sized> ResourceService for AddressObjectResourceService<AS> {
|
impl<AS: AddressbookStore> ResourceService for AddressObjectResourceService<AS> {
|
||||||
type PathComponents = AddressObjectPathComponents;
|
type PathComponents = AddressObjectPathComponents;
|
||||||
type Resource = AddressObjectResource;
|
type Resource = AddressObjectResource;
|
||||||
type MemberType = AddressObjectResource;
|
type MemberType = AddressObjectResource;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ struct MkcolRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
||||||
pub async fn route_mkcol<AS: AddressbookStore + ?Sized>(
|
pub async fn route_mkcol<AS: AddressbookStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
body: String,
|
body: String,
|
||||||
user: User,
|
user: User,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use tracing::instrument;
|
|||||||
use tracing_actix_web::RootSpan;
|
use tracing_actix_web::RootSpan;
|
||||||
|
|
||||||
#[instrument(parent = root_span.id(), skip(store, subscription_store, root_span, req))]
|
#[instrument(parent = root_span.id(), skip(store, subscription_store, root_span, req))]
|
||||||
pub async fn route_post<A: AddressbookStore + ?Sized, S: SubscriptionStore + ?Sized>(
|
pub async fn route_post<A: AddressbookStore, S: SubscriptionStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
body: String,
|
body: String,
|
||||||
user: User,
|
user: User,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub struct AddressbookMultigetRequest {
|
|||||||
href: Vec<String>,
|
href: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_objects_addressbook_multiget<AS: AddressbookStore + ?Sized>(
|
pub async fn get_objects_addressbook_multiget<AS: AddressbookStore>(
|
||||||
addressbook_multiget: &AddressbookMultigetRequest,
|
addressbook_multiget: &AddressbookMultigetRequest,
|
||||||
path: &str,
|
path: &str,
|
||||||
principal: &str,
|
principal: &str,
|
||||||
@@ -52,7 +52,7 @@ pub async fn get_objects_addressbook_multiget<AS: AddressbookStore + ?Sized>(
|
|||||||
Ok((result, not_found))
|
Ok((result, not_found))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_addressbook_multiget<AS: AddressbookStore + ?Sized>(
|
pub async fn handle_addressbook_multiget<AS: AddressbookStore>(
|
||||||
addr_multiget: AddressbookMultigetRequest,
|
addr_multiget: AddressbookMultigetRequest,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
user: &User,
|
user: &User,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub(crate) enum ReportRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(req, addr_store))]
|
#[instrument(skip(req, addr_store))]
|
||||||
pub async fn route_report_addressbook<AS: AddressbookStore + ?Sized>(
|
pub async fn route_report_addressbook<AS: AddressbookStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
body: String,
|
body: String,
|
||||||
user: User,
|
user: User,
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ pub(crate) struct SyncCollectionRequest {
|
|||||||
pub(crate) limit: Option<u64>,
|
pub(crate) limit: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_sync_collection<AS: AddressbookStore + ?Sized>(
|
pub async fn handle_sync_collection<AS: AddressbookStore>(
|
||||||
sync_collection: SyncCollectionRequest,
|
sync_collection: SyncCollectionRequest,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
user: &User,
|
user: &User,
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ use std::str::FromStr;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
||||||
|
|
||||||
pub struct AddressbookResourceService<AS: AddressbookStore + ?Sized, S: SubscriptionStore + ?Sized>
|
pub struct AddressbookResourceService<AS: AddressbookStore, S: SubscriptionStore>
|
||||||
{
|
{
|
||||||
addr_store: Arc<AS>,
|
addr_store: Arc<AS>,
|
||||||
__phantom_sub: PhantomData<S>,
|
__phantom_sub: PhantomData<S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: AddressbookStore + ?Sized, S: SubscriptionStore + ?Sized> AddressbookResourceService<A, S> {
|
impl<A: AddressbookStore, S: SubscriptionStore> AddressbookResourceService<A, S> {
|
||||||
pub fn new(addr_store: Arc<A>) -> Self {
|
pub fn new(addr_store: Arc<A>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
addr_store,
|
addr_store,
|
||||||
@@ -174,7 +174,7 @@ impl Resource for AddressbookResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl<AS: AddressbookStore + ?Sized, S: SubscriptionStore + ?Sized> ResourceService
|
impl<AS: AddressbookStore, S: SubscriptionStore> ResourceService
|
||||||
for AddressbookResourceService<AS, S>
|
for AddressbookResourceService<AS, S>
|
||||||
{
|
{
|
||||||
type MemberType = AddressObjectResource;
|
type MemberType = AddressObjectResource;
|
||||||
|
|||||||
@@ -29,11 +29,7 @@ pub fn configure_well_known(cfg: &mut web::ServiceConfig, carddav_root: String)
|
|||||||
cfg.service(web::redirect("/carddav", carddav_root).permanent());
|
cfg.service(web::redirect("/carddav", carddav_root).permanent());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn configure_dav<
|
pub fn configure_dav<AP: AuthenticationProvider, A: AddressbookStore, S: SubscriptionStore>(
|
||||||
AP: AuthenticationProvider,
|
|
||||||
A: AddressbookStore + ?Sized,
|
|
||||||
S: SubscriptionStore + ?Sized,
|
|
||||||
>(
|
|
||||||
cfg: &mut web::ServiceConfig,
|
cfg: &mut web::ServiceConfig,
|
||||||
auth_provider: Arc<AP>,
|
auth_provider: Arc<AP>,
|
||||||
store: Arc<A>,
|
store: Arc<A>,
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ use rustical_xml::{XmlDeserialize, XmlSerialize};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
||||||
|
|
||||||
pub struct PrincipalResourceService<A: AddressbookStore + ?Sized> {
|
pub struct PrincipalResourceService<A: AddressbookStore> {
|
||||||
addr_store: Arc<A>,
|
addr_store: Arc<A>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: AddressbookStore + ?Sized> PrincipalResourceService<A> {
|
impl<A: AddressbookStore> PrincipalResourceService<A> {
|
||||||
pub fn new(addr_store: Arc<A>) -> Self {
|
pub fn new(addr_store: Arc<A>) -> Self {
|
||||||
Self { addr_store }
|
Self { addr_store }
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ impl Resource for PrincipalResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl<A: AddressbookStore + ?Sized> ResourceService for PrincipalResourceService<A> {
|
impl<A: AddressbookStore> ResourceService for PrincipalResourceService<A> {
|
||||||
type PathComponents = (String,);
|
type PathComponents = (String,);
|
||||||
type MemberType = AddressbookResource;
|
type MemberType = AddressbookResource;
|
||||||
type Resource = PrincipalResource;
|
type Resource = PrincipalResource;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ struct UserPage {
|
|||||||
pub deleted_addressbooks: Vec<Addressbook>,
|
pub deleted_addressbooks: Vec<Addressbook>,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn route_user<CS: CalendarStore + ?Sized, AS: AddressbookStore + ?Sized>(
|
async fn route_user<CS: CalendarStore, AS: AddressbookStore>(
|
||||||
path: Path<String>,
|
path: Path<String>,
|
||||||
cal_store: Data<CS>,
|
cal_store: Data<CS>,
|
||||||
addr_store: Data<AS>,
|
addr_store: Data<AS>,
|
||||||
@@ -99,11 +99,7 @@ fn unauthorized_handler<B>(res: ServiceResponse<B>) -> actix_web::Result<ErrorHa
|
|||||||
Ok(ErrorHandlerResponse::Response(res))
|
Ok(ErrorHandlerResponse::Response(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn configure_frontend<
|
pub fn configure_frontend<AP: AuthenticationProvider, CS: CalendarStore, AS: AddressbookStore>(
|
||||||
AP: AuthenticationProvider,
|
|
||||||
CS: CalendarStore + ?Sized,
|
|
||||||
AS: AddressbookStore + ?Sized,
|
|
||||||
>(
|
|
||||||
cfg: &mut web::ServiceConfig,
|
cfg: &mut web::ServiceConfig,
|
||||||
auth_provider: Arc<AP>,
|
auth_provider: Arc<AP>,
|
||||||
cal_store: Arc<CS>,
|
cal_store: Arc<CS>,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ struct AddressbookPage {
|
|||||||
addressbook: Addressbook,
|
addressbook: Addressbook,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn route_addressbook<AS: AddressbookStore + ?Sized>(
|
pub async fn route_addressbook<AS: AddressbookStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
store: Data<AS>,
|
store: Data<AS>,
|
||||||
_user: User,
|
_user: User,
|
||||||
@@ -23,7 +23,7 @@ pub async fn route_addressbook<AS: AddressbookStore + ?Sized>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn route_addressbook_restore<AS: AddressbookStore + ?Sized>(
|
pub async fn route_addressbook_restore<AS: AddressbookStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
store: Data<AS>,
|
store: Data<AS>,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ struct CalendarPage {
|
|||||||
calendar: Calendar,
|
calendar: Calendar,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn route_calendar<C: CalendarStore + ?Sized>(
|
pub async fn route_calendar<C: CalendarStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
store: Data<C>,
|
store: Data<C>,
|
||||||
_user: User,
|
_user: User,
|
||||||
@@ -23,7 +23,7 @@ pub async fn route_calendar<C: CalendarStore + ?Sized>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn route_calendar_restore<CS: CalendarStore + ?Sized>(
|
pub async fn route_calendar_restore<CS: CalendarStore>(
|
||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
store: Data<CS>,
|
store: Data<CS>,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use derive_more::derive::Constructor;
|
|||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
#[derive(Constructor, Clone)]
|
#[derive(Constructor, Clone)]
|
||||||
pub struct ContactBirthdayStore<AS: AddressbookStore + ?Sized>(Arc<AS>);
|
pub struct ContactBirthdayStore<AS: AddressbookStore>(Arc<AS>);
|
||||||
|
|
||||||
fn birthday_calendar(addressbook: Addressbook) -> Calendar {
|
fn birthday_calendar(addressbook: Addressbook) -> Calendar {
|
||||||
Calendar {
|
Calendar {
|
||||||
@@ -35,7 +35,7 @@ fn birthday_calendar(addressbook: Addressbook) -> Calendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<AS: AddressbookStore + ?Sized> CalendarStore for ContactBirthdayStore<AS> {
|
impl<AS: AddressbookStore> CalendarStore for ContactBirthdayStore<AS> {
|
||||||
async fn get_calendar(&self, principal: &str, id: &str) -> Result<Calendar, Error> {
|
async fn get_calendar(&self, principal: &str, id: &str) -> Result<Calendar, Error> {
|
||||||
let addressbook = self.0.get_addressbook(principal, id).await?;
|
let addressbook = self.0.get_addressbook(principal, id).await?;
|
||||||
Ok(birthday_calendar(addressbook))
|
Ok(birthday_calendar(addressbook))
|
||||||
|
|||||||
@@ -8,11 +8,7 @@ use rustical_store::{AddressbookStore, CalendarStore, SubscriptionStore};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tracing_actix_web::TracingLogger;
|
use tracing_actix_web::TracingLogger;
|
||||||
|
|
||||||
pub fn make_app<
|
pub fn make_app<AS: AddressbookStore, CS: CalendarStore, S: SubscriptionStore>(
|
||||||
AS: AddressbookStore + ?Sized,
|
|
||||||
CS: CalendarStore + ?Sized,
|
|
||||||
S: SubscriptionStore + ?Sized,
|
|
||||||
>(
|
|
||||||
addr_store: Arc<AS>,
|
addr_store: Arc<AS>,
|
||||||
cal_store: Arc<CS>,
|
cal_store: Arc<CS>,
|
||||||
subscription_store: Arc<S>,
|
subscription_store: Arc<S>,
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ async fn get_data_stores(
|
|||||||
migrate: bool,
|
migrate: bool,
|
||||||
config: &DataStoreConfig,
|
config: &DataStoreConfig,
|
||||||
) -> Result<(
|
) -> Result<(
|
||||||
Arc<dyn AddressbookStore>,
|
Arc<impl AddressbookStore>,
|
||||||
Arc<dyn CalendarStore>,
|
Arc<impl CalendarStore>,
|
||||||
Arc<dyn SubscriptionStore>,
|
Arc<impl SubscriptionStore>,
|
||||||
Receiver<CollectionOperation>,
|
Receiver<CollectionOperation>,
|
||||||
)> {
|
)> {
|
||||||
Ok(match &config {
|
Ok(match &config {
|
||||||
|
|||||||
Reference in New Issue
Block a user