Skip to content

Commit

Permalink
fix: add VTIMEZONE to Appointments
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Larch <anna@nextcloud.com>
  • Loading branch information
miaulalala committed Jun 27, 2023
1 parent fd591c6 commit ee68d75
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions lib/Service/Appointments/BookingCalendarWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private function secondsToIso8601Duration(int $secs): string {
* @return string
* @throws RuntimeException
*/
public function write(AppointmentConfig $config, DateTimeImmutable $start, string $displayName, string $email, ?string $description = null) : string {
public function write(AppointmentConfig $config, DateTimeImmutable $start, string $displayName, string $email, string $timezone, ?string $description = null) : string {
$calendar = current($this->manager->getCalendarsForPrincipal($config->getPrincipalUri(), [$config->getTargetCalendarUri()]));
if (!($calendar instanceof ICreateFromString)) {
throw new RuntimeException('Could not find a public writable calendar for this principal');
Expand All @@ -113,7 +113,10 @@ public function write(AppointmentConfig $config, DateTimeImmutable $start, strin
'STATUS' => 'CONFIRMED',
'DTSTART' => $start,
'DTEND' => $start->setTimestamp($start->getTimestamp() + ($config->getLength()))
]
],
'VTIMEZONE' => [
'TZID' => $timezone
],
]);

if (!empty($description)) {
Expand Down Expand Up @@ -191,7 +194,10 @@ public function write(AppointmentConfig $config, DateTimeImmutable $start, strin
'STATUS' => 'CONFIRMED',
'DTSTART' => $prepStart,
'DTEND' => $start
]
],
'VTIMEZONE' => [
'TZID' => $timezone
],
]);

$prepCalendar->VEVENT->add('RELATED-TO', $vcalendar->VEVENT->{'UID'});
Expand Down Expand Up @@ -219,7 +225,10 @@ public function write(AppointmentConfig $config, DateTimeImmutable $start, strin
'STATUS' => 'CONFIRMED',
'DTSTART' => $followupStart,
'DTEND' => $followUpEnd
]
],
'VTIMEZONE' => [
'TZID' => $timezone
],
]);

$followUpCalendar->VEVENT->add('RELATED-TO', $vcalendar->VEVENT->{'UID'});
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/Appointments/BookingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function confirmBooking(Booking $booking, AppointmentConfig $config): Boo
throw new ClientException('Could not make sense of booking times');
}

$calendar = $this->calendarWriter->write($config, $startObj, $booking->getDisplayName(), $booking->getEmail(), $booking->getDescription());
$calendar = $this->calendarWriter->write($config, $startObj, $booking->getDisplayName(), $booking->getEmail(), $booking->getTimezone(), $booking->getDescription());
$booking->setConfirmed(true);
$this->bookingMapper->update($booking);

Expand Down

0 comments on commit ee68d75

Please sign in to comment.