JMAP for Calendars passing tests

This commit is contained in:
mdecimus
2025-10-16 16:55:56 +02:00
parent 96d2947cdd
commit 81b266797d
31 changed files with 2331 additions and 132 deletions

View File

@@ -414,7 +414,7 @@ impl JmapRight for CalendarRight {
CalendarRight::MayUpdatePrivate => &[Acl::ModifyPrivateProperties],
CalendarRight::MayRSVP => &[Acl::ModifyRSVP],
CalendarRight::MayShare => &[Acl::Share],
CalendarRight::MayDelete => &[Acl::Delete],
CalendarRight::MayDelete => &[Acl::Delete, Acl::RemoveItems],
}
}

View File

@@ -12,7 +12,7 @@ use crate::{
use calcard::jscalendar::JSCalendar;
use jmap_tools::{Element, Key, Property};
use serde::Serialize;
use std::{borrow::Cow, str::FromStr};
use std::{borrow::Cow, fmt::Display, str::FromStr};
use types::{blob::BlobId, id::Id};
#[derive(Debug, Clone, Default)]
@@ -398,3 +398,9 @@ impl serde::Serialize for CalendarEventNotificationType {
serializer.serialize_str(self.as_str())
}
}
impl Display for CalendarEventNotificationProperty {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.to_cow())
}
}

View File

@@ -9,7 +9,7 @@ use crate::{
request::{deserialize::DeserializeArguments, reference::MaybeIdReference},
};
use jmap_tools::{Element, Key, Property};
use std::{borrow::Cow, str::FromStr};
use std::{borrow::Cow, fmt::Display, str::FromStr};
use types::id::Id;
#[derive(Debug, Clone, Default)]
@@ -76,6 +76,15 @@ impl ParticipantIdentityProperty {
b"isDefault" => ParticipantIdentityProperty::IsDefault
)
}
fn as_str(&self) -> &'static str {
match self {
ParticipantIdentityProperty::Id => "id",
ParticipantIdentityProperty::Name => "name",
ParticipantIdentityProperty::CalendarAddress => "calendarAddress",
ParticipantIdentityProperty::IsDefault => "isDefault",
}
}
}
#[derive(Debug, Clone, Default)]
@@ -188,3 +197,9 @@ impl JmapObjectId for ParticipantIdentityProperty {
false
}
}
impl Display for ParticipantIdentityProperty {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.as_str().fmt(f)
}
}

View File

@@ -91,7 +91,7 @@ impl Element for PrincipalValue {
}
impl PrincipalProperty {
fn parse(value: &str) -> Option<Self> {
pub fn parse(value: &str) -> Option<Self> {
hashify::tiny_map!(value.as_bytes(),
b"id" => PrincipalProperty::Id,
b"type" => PrincipalProperty::Type,
@@ -103,6 +103,21 @@ impl PrincipalProperty {
b"accounts" => PrincipalProperty::Accounts,
)
}
pub fn as_str(&self) -> &'static str {
match self {
PrincipalProperty::Id => "id",
PrincipalProperty::Type => "type",
PrincipalProperty::Name => "name",
PrincipalProperty::Description => "description",
PrincipalProperty::Email => "email",
PrincipalProperty::Timezone => "timeZone",
PrincipalProperty::Capabilities => "capabilities",
PrincipalProperty::Accounts => "accounts",
PrincipalProperty::Capability(cap) => cap.as_str(),
PrincipalProperty::IdValue(_) => "",
}
}
}
impl PrincipalType {
@@ -331,3 +346,9 @@ impl JmapObjectId for PrincipalProperty {
false
}
}
impl Display for PrincipalProperty {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}

View File

@@ -12,7 +12,6 @@ use crate::{
types::date::UTCDate,
};
use ahash::AHashMap;
use calcard::icalendar::ICalendarDuration;
use serde::{Deserialize, Deserializer};
use types::{id::Id, type_state::DataType};
use utils::map::vec_map::VecMap;
@@ -210,7 +209,7 @@ pub struct CalendarCapabilities {
#[serde(rename(serialize = "maxDateTime"))]
pub max_date_time: UTCDate,
#[serde(rename(serialize = "maxExpandedQueryDuration"))]
pub max_expanded_query_duration: ICalendarDuration,
pub max_expanded_query_duration: String,
#[serde(rename(serialize = "maxParticipantsPerEvent"))]
pub max_participants_per_event: Option<usize>,
#[serde(rename(serialize = "mayCreateCalendar"))]
@@ -228,7 +227,7 @@ pub struct ContactsCapabilities {
#[derive(Debug, Clone, serde::Serialize)]
pub struct PrincipalAvailabilityCapabilities {
#[serde(rename(serialize = "maxAvailabilityDuration"))]
pub max_availability_duration: ICalendarDuration,
pub max_availability_duration: String,
}
#[derive(Debug, Clone, serde::Serialize)]