Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable26] Handle reminders where calendar name is null #37785

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
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
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