diff --git a/application/libraries/Caldav_sync.php b/application/libraries/Caldav_sync.php index 3e6f71aa..a8e6ff67 100644 --- a/application/libraries/Caldav_sync.php +++ b/application/libraries/Caldav_sync.php @@ -70,7 +70,8 @@ class Caldav_sync $caldav_calendar = $provider['settings']['caldav_calendar']; - $caldav_event_id = $this->CI->ics_file->generate_uid($appointment['id']) . '.ics'; + $caldav_event_id = + $appointment['id_caldav_calendar'] ?: $this->CI->ics_file->generate_uid($appointment['id']); $uri = $this->get_caldav_event_uri($caldav_calendar, $caldav_event_id); @@ -107,7 +108,8 @@ class Caldav_sync $caldav_calendar = $provider['settings']['caldav_calendar']; - $caldav_event_id = $this->CI->ics_file->generate_uid($unavailability['id']) . '.ics'; + $caldav_event_id = + $unavailability['id_caldav_calendar'] ?: $this->CI->ics_file->generate_uid($unavailability['id']); $uri = $this->get_caldav_event_uri($caldav_calendar, $caldav_event_id); @@ -420,7 +422,7 @@ class Caldav_sync */ private function get_caldav_event_uri(string $caldav_calendar, ?string $caldav_event_id = null): string { - return trim($caldav_calendar, '/') . ($caldav_event_id ? '/' . $caldav_event_id : ''); + return trim($caldav_calendar, '/') . ($caldav_event_id ? '/' . $caldav_event_id . '.ics' : ''); } /** diff --git a/application/libraries/Ics_file.php b/application/libraries/Ics_file.php index 64331982..4466936a 100644 --- a/application/libraries/Ics_file.php +++ b/application/libraries/Ics_file.php @@ -78,7 +78,7 @@ class Ics_file ->setEnd($appointment_end) ->setStatus('CONFIRMED') ->setSummary($service['name']) - ->setUid($this->generate_uid($appointment['id'])); + ->setUid($appointment['id_caldav_calendar'] ?: $this->generate_uid($appointment['id'])); if (!empty($service['location'])) { $location = new Location(); @@ -198,7 +198,7 @@ class Ics_file ->setEnd($unavailability_end) ->setStatus('CONFIRMED') ->setSummary('Unavailability') - ->setUid($this->generate_uid($unavailability['id'])); + ->setUid($unavailability['id_caldav_calendar'] ?: $this->generate_uid($unavailability['id'])); $event->setDescription(str_replace("\n", "\\n", (string) $unavailability['notes'])); diff --git a/application/libraries/Synchronization.php b/application/libraries/Synchronization.php index f5fa8e47..aed977c5 100644 --- a/application/libraries/Synchronization.php +++ b/application/libraries/Synchronization.php @@ -36,6 +36,7 @@ class Synchronization $this->CI->load->model('appointments_model'); $this->CI->load->library('google_sync'); + $this->CI->load->library('caldav_sync'); } /**