lift restriction on object_id and UID having to match

addresses #135
This commit is contained in:
Lennart
2025-11-01 21:48:37 +01:00
parent db144ebcae
commit 76b4194b94
21 changed files with 234 additions and 103 deletions

View File

@@ -11,7 +11,7 @@ use rustical_ical::CalendarObject;
use rustical_store::CalendarStore;
use rustical_store::auth::Principal;
use std::str::FromStr;
use tracing::{debug, error, instrument};
use tracing::{debug, instrument};
#[instrument(skip(cal_store))]
pub async fn get_event<C: CalendarStore>(
@@ -78,18 +78,10 @@ pub async fn put_event<C: CalendarStore>(
true
};
let Ok(object) = CalendarObject::from_ics(body.clone()) else {
let Ok(object) = CalendarObject::from_ics(body.clone(), Some(object_id)) else {
debug!("invalid calendar data:\n{body}");
return Err(Error::PreconditionFailed(Precondition::ValidCalendarData));
};
if object.get_uid() != object_id {
error!(
"Calendar object UID and file name not matching: UID={}, filename={}",
object.get_uid(),
object_id
);
return Err(Error::PreconditionFailed(Precondition::MatchingUid));
}
cal_store
.put_object(principal, calendar_id, object, overwrite)
.await?;