mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 07:02:24 +00:00
Add trash bin feature
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::CalDavContext;
|
||||
use crate::Error;
|
||||
use actix_web::HttpRequest;
|
||||
use actix_web::{
|
||||
web::{Data, Path},
|
||||
HttpResponse,
|
||||
@@ -11,12 +12,25 @@ pub async fn route_delete_calendar<A: CheckAuthentication, C: CalendarStore + ?S
|
||||
context: Data<CalDavContext<C>>,
|
||||
path: Path<(String, String)>,
|
||||
auth: AuthInfoExtractor<A>,
|
||||
req: HttpRequest,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let (principal, cid) = path.into_inner();
|
||||
if principal != auth.inner.user_id {
|
||||
return Err(Error::Unauthorized);
|
||||
}
|
||||
context.store.write().await.delete_calendar(&cid).await?;
|
||||
|
||||
let no_trash = req
|
||||
.headers()
|
||||
.get("X-No-Trashbin")
|
||||
.map(|val| matches!(val.to_str(), Ok("1")))
|
||||
.unwrap_or(false);
|
||||
|
||||
context
|
||||
.store
|
||||
.write()
|
||||
.await
|
||||
.delete_calendar(&cid, !no_trash)
|
||||
.await?;
|
||||
|
||||
Ok(HttpResponse::Ok().body(""))
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ pub async fn route_mkcol_calendar<A: CheckAuthentication, C: CalendarStore + ?Si
|
||||
timezone: request.calendar_timezone,
|
||||
color: request.calendar_color,
|
||||
description: request.calendar_description,
|
||||
deleted: false,
|
||||
deleted_at: None,
|
||||
};
|
||||
|
||||
match context.store.read().await.get_calendar(&cid).await {
|
||||
|
||||
Reference in New Issue
Block a user