Registry caching and directory synchronization
This commit is contained in:
4
crates/groupware/src/cache/calcard.rs
vendored
4
crates/groupware/src/cache/calcard.rs
vendored
@@ -37,11 +37,11 @@ pub(super) async fn build_calcard_resources(
|
||||
update_lock: Arc<UpdateLock>,
|
||||
) -> trc::Result<DavResources> {
|
||||
let is_calendar = matches!(sync_collection, SyncCollection::Calendar);
|
||||
let owner_account_info = server.account_info(account_id).await?;
|
||||
let owner_account_info = server.account(account_id).await?;
|
||||
let access_account_info = if account_id == access_account_id {
|
||||
owner_account_info.clone()
|
||||
} else {
|
||||
server.account_info(access_account_id).await?
|
||||
server.account(access_account_id).await?
|
||||
};
|
||||
let mut cache = DavResources {
|
||||
base_path: format!(
|
||||
|
||||
20
crates/groupware/src/cache/mod.rs
vendored
20
crates/groupware/src/cache/mod.rs
vendored
@@ -15,7 +15,9 @@ use calcard::{
|
||||
build_calcard_resources, build_simple_hierarchy, resource_from_addressbook,
|
||||
resource_from_calendar, resource_from_card, resource_from_event,
|
||||
};
|
||||
use common::{DavResource, DavResources, Server, UpdateLock, auth::AccountInfo, cache::LockResult};
|
||||
use common::{
|
||||
DavResource, DavResources, Server, UpdateLock, auth::AccountCache, cache::LockResult,
|
||||
};
|
||||
use file::{build_file_resources, build_nested_hierarchy, resource_from_file};
|
||||
use std::{sync::Arc, time::Instant};
|
||||
use store::{
|
||||
@@ -43,14 +45,14 @@ pub trait GroupwareCache: Sync + Send {
|
||||
|
||||
fn create_default_addressbook(
|
||||
&self,
|
||||
account_info_access: &AccountInfo,
|
||||
account_info_owner: &AccountInfo,
|
||||
account_info_access: &AccountCache,
|
||||
account_info_owner: &AccountCache,
|
||||
) -> impl Future<Output = trc::Result<Option<u32>>> + Send;
|
||||
|
||||
fn create_default_calendar(
|
||||
&self,
|
||||
account_info_access: &AccountInfo,
|
||||
account_info_owner: &AccountInfo,
|
||||
account_info_access: &AccountCache,
|
||||
account_info_owner: &AccountCache,
|
||||
) -> impl Future<Output = trc::Result<Option<u32>>> + Send;
|
||||
|
||||
fn get_or_create_default_calendar(
|
||||
@@ -321,8 +323,8 @@ impl GroupwareCache for Server {
|
||||
|
||||
async fn create_default_addressbook(
|
||||
&self,
|
||||
account_info_access: &AccountInfo,
|
||||
account_info_owner: &AccountInfo,
|
||||
account_info_access: &AccountCache,
|
||||
account_info_owner: &AccountCache,
|
||||
) -> trc::Result<Option<u32>> {
|
||||
if let Some(name) = &self.core.groupware.default_addressbook_name {
|
||||
let mut batch = BatchBuilder::new();
|
||||
@@ -364,8 +366,8 @@ impl GroupwareCache for Server {
|
||||
|
||||
async fn create_default_calendar(
|
||||
&self,
|
||||
account_info_access: &AccountInfo,
|
||||
account_info_owner: &AccountInfo,
|
||||
account_info_access: &AccountCache,
|
||||
account_info_owner: &AccountCache,
|
||||
) -> trc::Result<Option<u32>> {
|
||||
if let Some(name) = &self.core.groupware.default_calendar_name {
|
||||
let mut batch = BatchBuilder::new();
|
||||
|
||||
@@ -132,8 +132,7 @@ impl ItipIngest for Server {
|
||||
}
|
||||
}
|
||||
|
||||
let emails = account_info.addresses().collect::<Vec<_>>();
|
||||
let itip_snapshots = itip_snapshot(&itip, emails.as_slice(), false)?;
|
||||
let itip_snapshots = itip_snapshot(&itip, account_info.addresses(), false)?;
|
||||
if !itip_snapshots.sender_is_organizer_or_attendee(sender) {
|
||||
return Err(ItipIngestError::Message(
|
||||
ItipError::SenderIsNotOrganizerNorAttendee,
|
||||
@@ -141,7 +140,7 @@ impl ItipIngest for Server {
|
||||
}
|
||||
|
||||
// Obtain changedBy
|
||||
let changed_by = if let Some(id) = self.account_id_from_email(sender, false).await? {
|
||||
let changed_by = if let Some(id) = self.account_id_from_email(sender, true).await? {
|
||||
ChangedBy::PrincipalId(id)
|
||||
} else {
|
||||
ChangedBy::CalendarAddress(sender.into())
|
||||
@@ -180,7 +179,7 @@ impl ItipIngest for Server {
|
||||
.caused_by(trc::location!())?;
|
||||
|
||||
// Process the iTIP message
|
||||
let snapshots = itip_snapshot(&event.data.event, emails.as_slice(), false)?;
|
||||
let snapshots = itip_snapshot(&event.data.event, account_info.addresses(), false)?;
|
||||
let is_organizer_update = !itip_snapshots.organizer.email.is_local;
|
||||
match itip_process_message(
|
||||
&event.data.event,
|
||||
@@ -502,7 +501,7 @@ impl ItipIngest for Server {
|
||||
let mut batch = BatchBuilder::new();
|
||||
new_event
|
||||
.update(
|
||||
account_info.account_tenant_ids(rsvp.account_id),
|
||||
account_info.account_tenant_ids(),
|
||||
event,
|
||||
rsvp.account_id,
|
||||
rsvp.document_id,
|
||||
|
||||
@@ -137,7 +137,7 @@ impl ItipAutoExpunge for Server {
|
||||
.account(account_id)
|
||||
.await
|
||||
.caused_by(trc::location!())?
|
||||
.account_tenant_ids(account_id);
|
||||
.account_tenant_ids();
|
||||
|
||||
for document_id in destroy_ids {
|
||||
// Fetch event
|
||||
@@ -480,8 +480,7 @@ impl DestroyArchive<Archive<&ArchivedCalendarEvent>> {
|
||||
.deserialize::<CalendarEvent>()
|
||||
.caused_by(trc::location!())?;
|
||||
|
||||
let emails = account_info.addresses().collect::<Vec<_>>();
|
||||
if let Ok(messages) = itip_cancel(&event.data.event, emails.as_slice(), true) {
|
||||
if let Ok(messages) = itip_cancel(&event.data.event, account_info.addresses(), true) {
|
||||
ItipMessages::new(vec![messages])
|
||||
.queue(batch)
|
||||
.caused_by(trc::location!())?;
|
||||
|
||||
@@ -21,7 +21,7 @@ use calcard::{
|
||||
|
||||
pub fn itip_cancel(
|
||||
ical: &ICalendar,
|
||||
account_emails: &[&str],
|
||||
account_emails: &[String],
|
||||
is_deletion: bool,
|
||||
) -> Result<ItipMessage<ICalendar>, ItipError> {
|
||||
// Prepare iTIP message
|
||||
|
||||
@@ -12,7 +12,7 @@ use calcard::icalendar::ICalendar;
|
||||
|
||||
pub fn itip_create(
|
||||
ical: &mut ICalendar,
|
||||
account_emails: &[&str],
|
||||
account_emails: &[String],
|
||||
) -> Result<Vec<ItipMessage<ICalendar>>, ItipError> {
|
||||
let itip = itip_snapshot(ical, account_emails, false)?;
|
||||
if !itip.organizer.is_server_scheduling {
|
||||
|
||||
@@ -13,7 +13,7 @@ use calcard::icalendar::ICalendar;
|
||||
pub fn itip_update(
|
||||
ical: &mut ICalendar,
|
||||
old_ical: &ICalendar,
|
||||
account_emails: &[&str],
|
||||
account_emails: &[String],
|
||||
) -> Result<Vec<ItipMessage<ICalendar>>, ItipError> {
|
||||
let old_itip = itip_snapshot(old_ical, account_emails, false)?;
|
||||
match itip_snapshot(ical, account_emails, false) {
|
||||
|
||||
@@ -235,15 +235,15 @@ impl Attendee<'_> {
|
||||
}
|
||||
|
||||
impl Email {
|
||||
pub fn new(email: &str, local_addresses: &[&str]) -> Option<Self> {
|
||||
pub fn new(email: &str, local_addresses: &[String]) -> Option<Self> {
|
||||
email.contains('@').then(|| {
|
||||
let email = email.trim().trim_start_matches("mailto:").to_lowercase();
|
||||
let is_local = local_addresses.contains(&email.as_str());
|
||||
let is_local = local_addresses.contains(&email);
|
||||
Email { email, is_local }
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_uri(uri: &Uri, local_addresses: &[&str]) -> Option<Self> {
|
||||
pub fn from_uri(uri: &Uri, local_addresses: &[String]) -> Option<Self> {
|
||||
if let Uri::Location(uri) = uri {
|
||||
Email::new(uri.as_str(), local_addresses)
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,7 @@ use calcard::icalendar::{
|
||||
|
||||
pub fn itip_snapshot<'x, 'y>(
|
||||
ical: &'x ICalendar,
|
||||
account_emails: &'y [&str],
|
||||
account_emails: &'y [String],
|
||||
force_add_client_scheduling: bool,
|
||||
) -> Result<ItipSnapshots<'x>, ItipError> {
|
||||
if !ical.components.iter().any(|comp| {
|
||||
|
||||
Reference in New Issue
Block a user