mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 21:42:34 +00:00
calendarobject: Rename get_id to get_uid
This commit is contained in:
@@ -61,7 +61,7 @@ fn objects_response(
|
|||||||
) -> Result<MultistatusElement<CalendarObjectPropWrapper, String>, Error> {
|
) -> Result<MultistatusElement<CalendarObjectPropWrapper, String>, Error> {
|
||||||
let mut responses = Vec::new();
|
let mut responses = Vec::new();
|
||||||
for object in objects {
|
for object in objects {
|
||||||
let path = format!("{}/{}.ics", path, object.get_id());
|
let path = format!("{}/{}.ics", path, object.get_uid());
|
||||||
responses.push(
|
responses.push(
|
||||||
CalendarObjectResource {
|
CalendarObjectResource {
|
||||||
object,
|
object,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub async fn handle_sync_collection<C: CalendarStore>(
|
|||||||
|
|
||||||
let mut responses = Vec::new();
|
let mut responses = Vec::new();
|
||||||
for object in new_objects {
|
for object in new_objects {
|
||||||
let path = format!("{}/{}.ics", path, object.get_id());
|
let path = format!("{}/{}.ics", path, object.get_uid());
|
||||||
responses.push(
|
responses.push(
|
||||||
CalendarObjectResource {
|
CalendarObjectResource {
|
||||||
object,
|
object,
|
||||||
|
|||||||
@@ -82,10 +82,10 @@ pub async fn put_event<C: CalendarStore>(
|
|||||||
debug!("invalid calendar data:\n{body}");
|
debug!("invalid calendar data:\n{body}");
|
||||||
return Err(Error::PreconditionFailed(Precondition::ValidCalendarData));
|
return Err(Error::PreconditionFailed(Precondition::ValidCalendarData));
|
||||||
};
|
};
|
||||||
if object.get_id() != object_id {
|
if object.get_uid() != object_id {
|
||||||
error!(
|
error!(
|
||||||
"Calendar object UID and file name not matching: UID={}, filename={}",
|
"Calendar object UID and file name not matching: UID={}, filename={}",
|
||||||
object.get_id(),
|
object.get_uid(),
|
||||||
object_id
|
object_id
|
||||||
);
|
);
|
||||||
return Err(Error::PreconditionFailed(Precondition::MatchingUid));
|
return Err(Error::PreconditionFailed(Precondition::MatchingUid));
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub struct CalendarObjectResource {
|
|||||||
|
|
||||||
impl ResourceName for CalendarObjectResource {
|
impl ResourceName for CalendarObjectResource {
|
||||||
fn get_name(&self) -> String {
|
fn get_name(&self) -> String {
|
||||||
format!("{}.ics", self.object.get_id())
|
format!("{}.ics", self.object.get_uid())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ impl CalendarObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_id(&self) -> &str {
|
pub fn get_uid(&self) -> &str {
|
||||||
match &self.data {
|
match &self.data {
|
||||||
// We've made sure before that the first component exists and all components share the
|
// We've made sure before that the first component exists and all components share the
|
||||||
// same UID
|
// same UID
|
||||||
@@ -233,7 +233,7 @@ impl CalendarObject {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_etag(&self) -> String {
|
pub fn get_etag(&self) -> String {
|
||||||
let mut hasher = Sha256::new();
|
let mut hasher = Sha256::new();
|
||||||
hasher.update(self.get_id());
|
hasher.update(self.get_uid());
|
||||||
hasher.update(self.get_ics());
|
hasher.update(self.get_ics());
|
||||||
format!("\"{:x}\"", hasher.finalize())
|
format!("\"{:x}\"", hasher.finalize())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use crate::synctoken::format_synctoken;
|
use crate::synctoken::format_synctoken;
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use rustical_ical::CalendarObjectType;
|
use rustical_ical::CalendarObjectType;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
pub struct CalendarMetadata {
|
pub struct CalendarMetadata {
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ impl TryFrom<CalendarObjectRow> for CalendarObject {
|
|||||||
|
|
||||||
fn try_from(value: CalendarObjectRow) -> Result<Self, Self::Error> {
|
fn try_from(value: CalendarObjectRow) -> Result<Self, Self::Error> {
|
||||||
let object = Self::from_ics(value.ics)?;
|
let object = Self::from_ics(value.ics)?;
|
||||||
if object.get_id() != value.id {
|
if object.get_uid() != value.id {
|
||||||
return Err(rustical_store::Error::IcalError(
|
return Err(rustical_store::Error::IcalError(
|
||||||
rustical_ical::Error::InvalidData(format!(
|
rustical_ical::Error::InvalidData(format!(
|
||||||
"object_id={} and UID={} don't match",
|
"object_id={} and UID={} don't match",
|
||||||
object.get_id(),
|
object.get_uid(),
|
||||||
value.id
|
value.id
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
@@ -355,7 +355,7 @@ impl SqliteCalendarStore {
|
|||||||
object: CalendarObject,
|
object: CalendarObject,
|
||||||
overwrite: bool,
|
overwrite: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let (object_id, ics) = (object.get_id(), object.get_ics());
|
let (object_id, ics) = (object.get_uid(), object.get_ics());
|
||||||
|
|
||||||
let first_occurence = object
|
let first_occurence = object
|
||||||
.get_first_occurence()
|
.get_first_occurence()
|
||||||
@@ -678,7 +678,7 @@ impl CalendarStore for SqliteCalendarStore {
|
|||||||
.await
|
.await
|
||||||
.map_err(crate::Error::from)?;
|
.map_err(crate::Error::from)?;
|
||||||
|
|
||||||
let object_id = object.get_id().to_owned();
|
let object_id = object.get_uid().to_owned();
|
||||||
|
|
||||||
let calendar = Self::_get_calendar(&mut *tx, &principal, &cal_id, true).await?;
|
let calendar = Self::_get_calendar(&mut *tx, &principal, &cal_id, true).await?;
|
||||||
if calendar.subscription_url.is_some() {
|
if calendar.subscription_url.is_some() {
|
||||||
|
|||||||
Reference in New Issue
Block a user