mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
caldav: some minor refactoring
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2010,6 +2010,7 @@ dependencies = [
|
||||
"actix-web",
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"derive_more 1.0.0",
|
||||
"futures-util",
|
||||
"itertools",
|
||||
"log",
|
||||
|
||||
@@ -40,6 +40,7 @@ pub async fn route_report_calendar<A: CheckAuthentication, C: CalendarStore + ?S
|
||||
cal_store: Data<RwLock<C>>,
|
||||
prefix: Data<ServicePrefix>,
|
||||
) -> Result<impl Responder, Error> {
|
||||
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<A: CheckAuthentication, C: CalendarStore + ?S
|
||||
|
||||
Ok(match request.clone() {
|
||||
ReportRequest::CalendarQuery(cal_query) => {
|
||||
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) => {
|
||||
|
||||
@@ -20,3 +20,4 @@ itertools = "0.13"
|
||||
thiserror = "1.0"
|
||||
roxmltree = "0.20"
|
||||
log = "0.4"
|
||||
derive_more = { version = "1.0.0", features = ["deref"] }
|
||||
|
||||
@@ -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<A: CheckAuthentication, R: ResourceService>(
|
||||
> {
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user