mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 05:52:19 +00:00
@@ -82,7 +82,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
||||
let objects = expanded_cals
|
||||
.into_iter()
|
||||
.map(|cal| cal.generate())
|
||||
.map(CalendarObject::from_ics)
|
||||
.map(|ics| CalendarObject::from_ics(ics, None))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let new_cal = Calendar {
|
||||
principal,
|
||||
|
||||
@@ -61,7 +61,7 @@ fn objects_response(
|
||||
) -> Result<MultistatusElement<CalendarObjectPropWrapper, String>, Error> {
|
||||
let mut responses = Vec::new();
|
||||
for object in objects {
|
||||
let path = format!("{}/{}.ics", path, object.get_uid());
|
||||
let path = format!("{}/{}.ics", path, object.get_id());
|
||||
responses.push(
|
||||
CalendarObjectResource {
|
||||
object,
|
||||
|
||||
@@ -33,7 +33,7 @@ pub async fn handle_sync_collection<C: CalendarStore>(
|
||||
|
||||
let mut responses = Vec::new();
|
||||
for object in new_objects {
|
||||
let path = format!("{}/{}.ics", path, object.get_uid());
|
||||
let path = format!("{}/{}.ics", path, object.get_id());
|
||||
responses.push(
|
||||
CalendarObjectResource {
|
||||
object,
|
||||
|
||||
@@ -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?;
|
||||
|
||||
@@ -21,7 +21,7 @@ pub struct CalendarObjectResource {
|
||||
|
||||
impl ResourceName for CalendarObjectResource {
|
||||
fn get_name(&self) -> String {
|
||||
format!("{}.ics", self.object.get_uid())
|
||||
format!("{}.ics", self.object.get_id())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ pub enum Precondition {
|
||||
#[error("valid-calendar-data")]
|
||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||
ValidCalendarData,
|
||||
#[error("matching-uid")]
|
||||
MatchingUid,
|
||||
}
|
||||
|
||||
impl IntoResponse for Precondition {
|
||||
|
||||
Reference in New Issue
Block a user