Skip to content

Commit

Permalink
Merge pull request #37785 from nextcloud/backport/36217/stable26
Browse files Browse the repository at this point in the history
[stable26] Handle reminders where calendar name is null
  • Loading branch information
blizzz authored May 17, 2023
2 parents 8cdbbbe + 0d18fc5 commit c24bd06
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/Reminder/INotificationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ interface INotificationProvider {
* Send notification
*
* @param VEvent $vevent
* @param string $calendarDisplayName
* @param string|null $calendarDisplayName
* @param string[] $principalEmailAddresses All email addresses associated to the principal owning the calendar object
* @param IUser[] $users
* @return void
*/
public function send(VEvent $vevent,
string $calendarDisplayName,
?string $calendarDisplayName,
array $principalEmailAddresses,
array $users = []): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ public function __construct(LoggerInterface $logger,
* Send notification
*
* @param VEvent $vevent
* @param string $calendarDisplayName
* @param string|null $calendarDisplayName
* @param string[] $principalEmailAddresses
* @param IUser[] $users
* @return void
*/
abstract public function send(VEvent $vevent,
string $calendarDisplayName,
?string $calendarDisplayName,
array $principalEmailAddresses,
array $users = []): void;

Expand Down Expand Up @@ -185,4 +185,8 @@ protected function getDTEndFromEvent(VEvent $vevent):Property\ICalendar\DateTime

return clone $vevent->DTSTART;
}

protected function getCalendarDisplayNameFallback(string $lang): string {
return $this->getL10NForLang($lang)->t('Untitled calendar');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public function __construct(IConfig $config,
* Send out notification via email
*
* @param VEvent $vevent
* @param string $calendarDisplayName
* @param string|null $calendarDisplayName
* @param string[] $principalEmailAddresses
* @param array $users
* @throws \Exception
*/
public function send(VEvent $vevent,
string $calendarDisplayName,
?string $calendarDisplayName,
array $principalEmailAddresses,
array $users = []):void {
$fallbackLanguage = $this->getFallbackLanguage();
Expand Down Expand Up @@ -115,7 +115,7 @@ public function send(VEvent $vevent,
$template = $this->mailer->createEMailTemplate('dav.calendarReminder');
$template->addHeader();
$this->addSubjectAndHeading($template, $l10n, $vevent);
$this->addBulletList($template, $l10n, $calendarDisplayName, $vevent);
$this->addBulletList($template, $l10n, $calendarDisplayName ?? $this->getCalendarDisplayNameFallback($lang), $vevent);
$template->addFooter();

foreach ($emailAddresses as $emailAddress) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,29 @@ public function __construct(IConfig $config,
* Send push notification to all users.
*
* @param VEvent $vevent
* @param string $calendarDisplayName
* @param string|null $calendarDisplayName
* @param string[] $principalEmailAddresses
* @param IUser[] $users
* @throws \Exception
*/
public function send(VEvent $vevent,
string $calendarDisplayName,
?string $calendarDisplayName,
array $principalEmailAddresses,
array $users = []):void {
if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'no') !== 'yes') {
return;
}

$eventDetails = $this->extractEventDetails($vevent);
$eventDetails['calendar_displayname'] = $calendarDisplayName;
$eventUUID = (string) $vevent->UID;
if (!$eventUUID) {
return;
};
$eventUUIDHash = hash('sha256', $eventUUID, false);

foreach ($users as $user) {
$eventDetails['calendar_displayname'] = $calendarDisplayName ?? $this->getCalendarDisplayNameFallback($this->l10nFactory->getUserLanguage($user));

/** @var INotification $notification */
$notification = $this->manager->createNotification();
$notification->setApp(Application::APP_ID)
Expand Down

0 comments on commit c24bd06

Please sign in to comment.