mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-21 12:59:22 +00:00
23 lines
662 B
Rust
23 lines
662 B
Rust
use crate::CalDavContext;
|
|
use crate::Error;
|
|
use actix_web::{
|
|
web::{Data, Path},
|
|
HttpResponse,
|
|
};
|
|
use rustical_auth::{AuthInfoExtractor, CheckAuthentication};
|
|
use rustical_store::CalendarStore;
|
|
|
|
pub async fn route_delete_calendar<A: CheckAuthentication, C: CalendarStore + ?Sized>(
|
|
context: Data<CalDavContext<C>>,
|
|
path: Path<(String, String)>,
|
|
auth: AuthInfoExtractor<A>,
|
|
) -> 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?;
|
|
|
|
Ok(HttpResponse::Ok().body(""))
|
|
}
|