JMAP for Calendars implementation (closes #1947)
This commit is contained in:
15
crates/groupware/src/cache/calcard.rs
vendored
15
crates/groupware/src/cache/calcard.rs
vendored
@@ -15,7 +15,8 @@ use crate::{
|
||||
};
|
||||
use calcard::common::timezone::Tz;
|
||||
use common::{
|
||||
DavName, DavPath, DavResource, DavResourceMetadata, DavResources, Server, auth::AccessToken,
|
||||
DavName, DavPath, DavResource, DavResourceMetadata, DavResources, Server,
|
||||
TinyCalendarPreferences, auth::AccessToken,
|
||||
};
|
||||
use directory::backend::internal::manage::ManageDirectory;
|
||||
use std::sync::Arc;
|
||||
@@ -295,11 +296,15 @@ pub(super) fn resource_from_calendar(calendar: &ArchivedCalendar, document_id: u
|
||||
grants: Bitmap::from(&acl.grants),
|
||||
})
|
||||
.collect(),
|
||||
tz: calendar
|
||||
preferences: calendar
|
||||
.preferences
|
||||
.first()
|
||||
.and_then(|pref| pref.time_zone.tz())
|
||||
.unwrap_or(Tz::UTC),
|
||||
.iter()
|
||||
.map(|pref| TinyCalendarPreferences {
|
||||
account_id: pref.account_id.to_native(),
|
||||
flags: pref.flags.to_native(),
|
||||
tz: pref.time_zone.tz().unwrap_or(Tz::UTC),
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
1
crates/groupware/src/cache/mod.rs
vendored
1
crates/groupware/src/cache/mod.rs
vendored
@@ -327,7 +327,6 @@ impl GroupwareCache for Server {
|
||||
.await?;
|
||||
AddressBook {
|
||||
name: name.clone(),
|
||||
is_default: true,
|
||||
preferences: vec![AddressBookPreferences {
|
||||
account_id,
|
||||
name: format!(
|
||||
|
||||
@@ -31,6 +31,7 @@ pub const CALENDAR_SUBSCRIBED: u16 = 1;
|
||||
pub const CALENDAR_INVISIBLE: u16 = 1 << 1;
|
||||
pub const CALENDAR_AVAILABILITY_NONE: u16 = 1 << 2;
|
||||
pub const CALENDAR_AVAILABILITY_ATTENDING: u16 = 1 << 3;
|
||||
pub const CALENDAR_AVAILABILITY_ALL: u16 = 1 << 4;
|
||||
|
||||
#[derive(
|
||||
rkyv::Archive, rkyv::Deserialize, rkyv::Serialize, Debug, Default, Clone, PartialEq, Eq,
|
||||
@@ -84,7 +85,6 @@ pub const EVENT_INVITE_SELF: u16 = 1;
|
||||
pub const EVENT_INVITE_OTHERS: u16 = 1 << 1;
|
||||
pub const EVENT_HIDE_ATTENDEES: u16 = 1 << 2;
|
||||
pub const EVENT_DRAFT: u16 = 1 << 3;
|
||||
pub const EVENT_ORIGIN: u16 = 1 << 4;
|
||||
|
||||
pub const EVENT_NOTIFICATION_IS_DRAFT: u16 = 1;
|
||||
pub const EVENT_NOTIFICATION_IS_CHANGE: u16 = 1 << 1;
|
||||
|
||||
@@ -19,7 +19,6 @@ pub struct AddressBook {
|
||||
pub name: String,
|
||||
pub preferences: Vec<AddressBookPreferences>,
|
||||
pub subscribers: Vec<u32>,
|
||||
pub is_default: bool,
|
||||
pub dead_properties: DeadProperty,
|
||||
pub acls: Vec<AclGrant>,
|
||||
pub created: i64,
|
||||
|
||||
@@ -137,12 +137,13 @@ impl From<SyncCollection> for DavResourceName {
|
||||
}
|
||||
|
||||
pub trait DavCalendarResource {
|
||||
fn calendar_default_tz(&self, calendar_id: u32) -> Option<Tz>;
|
||||
fn calendar_default_tz(&self, calendar_id: u32, account_id: u32) -> Option<Tz>;
|
||||
}
|
||||
|
||||
impl DavCalendarResource for DavResources {
|
||||
fn calendar_default_tz(&self, calendar_id: u32) -> Option<Tz> {
|
||||
fn calendar_default_tz(&self, calendar_id: u32, account_id: u32) -> Option<Tz> {
|
||||
self.container_resource_by_id(calendar_id)
|
||||
.and_then(|c| c.timezone())
|
||||
.and_then(|c| c.calendar_preferences(account_id))
|
||||
.map(|p| p.tz)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user