caldav: Refactoring to for consistent terminology between resources and resource services

This commit is contained in:
Lennart
2024-09-29 14:00:06 +02:00
parent 7f164da438
commit 2a347f0616
8 changed files with 58 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
use crate::{
event::resource::{EventFile, EventProp},
event::resource::{EventProp, EventResource},
Error,
};
use actix_web::{
@@ -87,7 +87,7 @@ pub async fn handle_calendar_multiget<C: CalendarStore + ?Sized>(
for event in events {
let path = format!("{}/{}", req.path(), event.get_uid());
responses.push(
EventFile::from(event)
EventResource::from(event)
.propfind(prefix, path, props.clone())
.await?,
);

View File

@@ -9,7 +9,7 @@ use serde::Deserialize;
use tokio::sync::RwLock;
use crate::{
event::resource::{EventFile, EventProp},
event::resource::{EventProp, EventResource},
Error,
};
@@ -126,7 +126,7 @@ pub async fn handle_calendar_query<C: CalendarStore + ?Sized>(
for event in events {
let path = format!("{}/{}", req.path(), event.get_uid());
responses.push(
EventFile::from(event)
EventResource::from(event)
.propfind(prefix, path, props.clone())
.await?,
);

View File

@@ -15,7 +15,7 @@ use serde::Deserialize;
use tokio::sync::RwLock;
use crate::{
event::resource::{EventFile, EventProp},
event::resource::{EventProp, EventResource},
Error,
};
@@ -73,7 +73,7 @@ pub async fn handle_sync_collection<C: CalendarStore + ?Sized>(
for event in new_events {
let path = format!("{}/{}", req.path(), event.get_uid());
responses.push(
EventFile::from(event)
EventResource::from(event)
.propfind(prefix, path, props.clone())
.await?,
);

View File

@@ -1,4 +1,4 @@
use crate::event::resource::EventFile;
use crate::event::resource::EventResource;
use crate::Error;
use actix_web::{web::Data, HttpRequest};
use anyhow::anyhow;
@@ -19,7 +19,7 @@ use super::prop::{
SupportedReportSet, UserPrivilegeSet,
};
pub struct CalendarResource<C: CalendarStore + ?Sized> {
pub struct CalendarResourceService<C: CalendarStore + ?Sized> {
pub cal_store: Arc<RwLock<C>>,
pub path: String,
pub principal: String,
@@ -89,9 +89,9 @@ impl InvalidProperty for CalendarProp {
}
#[derive(Clone, Debug, From, Into)]
pub struct CalendarFile(Calendar);
pub struct CalendarResource(Calendar);
impl Resource for CalendarFile {
impl Resource for CalendarResource {
type PropName = CalendarPropName;
type Prop = CalendarProp;
type Error = Error;
@@ -226,10 +226,10 @@ impl Resource for CalendarFile {
}
#[async_trait(?Send)]
impl<C: CalendarStore + ?Sized> ResourceService for CalendarResource<C> {
type MemberType = EventFile;
impl<C: CalendarStore + ?Sized> ResourceService for CalendarResourceService<C> {
type MemberType = EventResource;
type PathComponents = (String, String); // principal, calendar_id
type File = CalendarFile;
type File = CalendarResource;
type Error = Error;
async fn get_file(&self) -> Result<Self::File, Error> {