mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 18:52:26 +00:00
Refactoring to remove CalDavContext
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use crate::CalDavContext;
|
||||
use crate::Error;
|
||||
use actix_web::web::{Data, Path};
|
||||
use actix_web::HttpResponse;
|
||||
@@ -6,6 +5,7 @@ use rustical_store::auth::User;
|
||||
use rustical_store::model::Calendar;
|
||||
use rustical_store::CalendarStore;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone, Debug)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
@@ -57,7 +57,7 @@ pub async fn route_mkcalendar<C: CalendarStore + ?Sized>(
|
||||
path: Path<(String, String)>,
|
||||
body: String,
|
||||
user: User,
|
||||
context: Data<CalDavContext<C>>,
|
||||
store: Data<RwLock<C>>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let (principal, cal_id) = path.into_inner();
|
||||
if principal != user.id {
|
||||
@@ -79,13 +79,7 @@ pub async fn route_mkcalendar<C: CalendarStore + ?Sized>(
|
||||
synctoken: 0,
|
||||
};
|
||||
|
||||
match context
|
||||
.store
|
||||
.read()
|
||||
.await
|
||||
.get_calendar(&principal, &cal_id)
|
||||
.await
|
||||
{
|
||||
match store.read().await.get_calendar(&principal, &cal_id).await {
|
||||
Err(rustical_store::Error::NotFound) => {
|
||||
// No conflict, no worries
|
||||
}
|
||||
@@ -99,7 +93,7 @@ pub async fn route_mkcalendar<C: CalendarStore + ?Sized>(
|
||||
}
|
||||
}
|
||||
|
||||
match context.store.write().await.insert_calendar(calendar).await {
|
||||
match store.write().await.insert_calendar(calendar).await {
|
||||
// The spec says we should return a mkcalendar-response but I don't know what goes into it.
|
||||
// However, it works without one but breaks on iPadOS when using an empty one :)
|
||||
Ok(()) => Ok(HttpResponse::Created()
|
||||
|
||||
Reference in New Issue
Block a user