Skip to content
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
Handle reminders where calendar name is null
This adds an interface change, but that's not a public API.

We're handling this in the providers and not in ReminderService because
the fallback is translated with the user's language.

Signed-off-by: Thomas Citharel <[email protected]>
  • Loading branch information
tcitworld committed Apr 21, 2023
commit f3f37001b4c0cf72dbe13ecbc30dac0db1c3f694
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