From e9e16a71f0b55033ba6d10b73b29ff6a4f19d219 Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Sun, 29 Sep 2024 14:40:28 +0200 Subject: [PATCH] caldav: some minor refactoring --- Cargo.lock | 1 + crates/caldav/src/calendar/methods/report/mod.rs | 5 +++-- crates/dav/Cargo.toml | 1 + crates/dav/src/methods/propfind.rs | 7 ++++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6cf7140..0e0f290 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2010,6 +2010,7 @@ dependencies = [ "actix-web", "anyhow", "async-trait", + "derive_more 1.0.0", "futures-util", "itertools", "log", diff --git a/crates/caldav/src/calendar/methods/report/mod.rs b/crates/caldav/src/calendar/methods/report/mod.rs index c05d1eb..39e8194 100644 --- a/crates/caldav/src/calendar/methods/report/mod.rs +++ b/crates/caldav/src/calendar/methods/report/mod.rs @@ -40,6 +40,7 @@ pub async fn route_report_calendar>, prefix: Data, ) -> Result { + let prefix = prefix.into_inner(); let (principal, cid) = path.into_inner(); if principal != auth.inner.user_id { return Err(Error::Unauthorized); @@ -51,10 +52,10 @@ pub async fn route_report_calendar { - handle_calendar_query(cal_query, req, &prefix.0, &principal, &cid, &cal_store).await? + handle_calendar_query(cal_query, req, &prefix, &principal, &cid, &cal_store).await? } ReportRequest::CalendarMultiget(cal_multiget) => { - handle_calendar_multiget(cal_multiget, req, &prefix.0, &principal, &cid, &cal_store) + handle_calendar_multiget(cal_multiget, req, &prefix, &principal, &cid, &cal_store) .await? } ReportRequest::SyncCollection(sync_collection) => { diff --git a/crates/dav/Cargo.toml b/crates/dav/Cargo.toml index ca87654..5342058 100644 --- a/crates/dav/Cargo.toml +++ b/crates/dav/Cargo.toml @@ -20,3 +20,4 @@ itertools = "0.13" thiserror = "1.0" roxmltree = "0.20" log = "0.4" +derive_more = { version = "1.0.0", features = ["deref"] } diff --git a/crates/dav/src/methods/propfind.rs b/crates/dav/src/methods/propfind.rs index e775a46..17d2c0d 100644 --- a/crates/dav/src/methods/propfind.rs +++ b/crates/dav/src/methods/propfind.rs @@ -8,11 +8,13 @@ use crate::xml::TagList; use crate::Error; use actix_web::web::{Data, Path}; use actix_web::HttpRequest; +use derive_more::derive::Deref; use log::debug; use rustical_auth::{AuthInfoExtractor, CheckAuthentication}; use serde::Deserialize; // This is not the final place for this struct +#[derive(Deref)] pub struct ServicePrefix(pub String); #[derive(Deserialize, Clone, Debug)] @@ -53,11 +55,10 @@ pub async fn route_propfind( > { debug!("{body}"); let auth_info = auth.inner; - let prefix = prefix.0.to_owned(); - let path_components = path_components.into_inner(); + let prefix = prefix.into_inner(); let path = req.path().to_owned(); - let resource_service = R::new(&req, &auth_info, path_components.clone()).await?; + let resource_service = R::new(&req, &auth_info, path_components.into_inner()).await?; // A request body is optional. If empty we MUST return all props let propfind: PropfindElement = if !body.is_empty() {