Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions lib/Service/Appointments/BookingCalendarWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function write(AppointmentConfig $config,
$filename = $this->random->generate(32, ISecureRandom::CHAR_ALPHANUMERIC);

try {
$calendar->createFromString($filename . '.ics', $vcalendar->serialize());
$this->createFromString($calendar, $filename . '.ics', $vcalendar->serialize());
} catch (CalendarException $e) {
throw new RuntimeException('Could not write event for appointment config id ' . $config->getId() . ' to calendar: ' . $e->getMessage(), 0, $e);
}
Expand Down Expand Up @@ -202,7 +202,7 @@ public function write(AppointmentConfig $config,
$prepFileName = $this->random->generate(32, ISecureRandom::CHAR_ALPHANUMERIC);

try {
$calendar->createFromString($prepFileName . '.ics', $prepCalendar->serialize());
$this->createFromString($calendar, $prepFileName . '.ics', $prepCalendar->serialize());
} catch (CalendarException $e) {
throw new RuntimeException('Could not write event for appointment config id ' . $config->getId() . ' to calendar: ' . $e->getMessage(), 0, $e);
}
Expand Down Expand Up @@ -235,11 +235,32 @@ public function write(AppointmentConfig $config,
$followUpFilename = $this->random->generate(32, ISecureRandom::CHAR_ALPHANUMERIC);

try {
$calendar->createFromString($followUpFilename . '.ics', $followUpCalendar->serialize());
$this->createFromString($calendar, $followUpFilename . '.ics', $followUpCalendar->serialize());
} catch (CalendarException $e) {
throw new RuntimeException('Could not write event for appointment config id ' . $config->getId() . ' to calendar: ' . $e->getMessage(), 0, $e);
}
}
return $vcalendar->serialize();
}

/**
* Compatibility adapter for Nextcloud >= 32 for the ICreateFromString interface in OCP.
*
* @throws CalendarException
*/
private function createFromString(
ICreateFromString $calendar,
string $fileName,
string $ics,
): void {
// TODO: drop condition once we only support Nextcloud >= 32
// Need to use the new minimal method here since the original one was fixed starting
// from Nextcloud 32. The behavior differs a bit. The old, unpatched one and the minimal
// one are not sending email invitations which we want to leverage here.
if (method_exists($calendar, 'createFromStringMinimal')) {
$calendar->createFromStringMinimal($fileName . '.ics', $ics);
} else {
$calendar->createFromString($fileName . '.ics', $ics);
}
}
}
Loading