Skip to content

Commit e63720b

Browse files
authored
Merge pull request #36217 from nextcloud/handle-push-notification-with-no-calendar-name
Handle reminders where calendar name is null
2 parents ed2b28b + 62739ec commit e63720b

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

apps/dav/lib/CalDAV/Reminder/INotificationProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ interface INotificationProvider {
4242
* Send notification
4343
*
4444
* @param VEvent $vevent
45-
* @param string $calendarDisplayName
45+
* @param string|null $calendarDisplayName
4646
* @param string[] $principalEmailAddresses All email addresses associated to the principal owning the calendar object
4747
* @param IUser[] $users
4848
* @return void
4949
*/
5050
public function send(VEvent $vevent,
51-
string $calendarDisplayName,
51+
?string $calendarDisplayName,
5252
array $principalEmailAddresses,
5353
array $users = []): void;
5454
}

apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ public function __construct(LoggerInterface $logger,
8282
* Send notification
8383
*
8484
* @param VEvent $vevent
85-
* @param string $calendarDisplayName
85+
* @param string|null $calendarDisplayName
8686
* @param string[] $principalEmailAddresses
8787
* @param IUser[] $users
8888
* @return void
8989
*/
9090
abstract public function send(VEvent $vevent,
91-
string $calendarDisplayName,
91+
?string $calendarDisplayName,
9292
array $principalEmailAddresses,
9393
array $users = []): void;
9494

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

186186
return clone $vevent->DTSTART;
187187
}
188+
189+
protected function getCalendarDisplayNameFallback(string $lang): string {
190+
return $this->getL10NForLang($lang)->t('Untitled calendar');
191+
}
188192
}

apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ public function __construct(IConfig $config,
7070
* Send out notification via email
7171
*
7272
* @param VEvent $vevent
73-
* @param string $calendarDisplayName
73+
* @param string|null $calendarDisplayName
7474
* @param string[] $principalEmailAddresses
7575
* @param array $users
7676
* @throws \Exception
7777
*/
7878
public function send(VEvent $vevent,
79-
string $calendarDisplayName,
79+
?string $calendarDisplayName,
8080
array $principalEmailAddresses,
8181
array $users = []):void {
8282
$fallbackLanguage = $this->getFallbackLanguage();
@@ -115,7 +115,7 @@ public function send(VEvent $vevent,
115115
$template = $this->mailer->createEMailTemplate('dav.calendarReminder');
116116
$template->addHeader();
117117
$this->addSubjectAndHeading($template, $l10n, $vevent);
118-
$this->addBulletList($template, $l10n, $calendarDisplayName, $vevent);
118+
$this->addBulletList($template, $l10n, $calendarDisplayName ?? $this->getCalendarDisplayNameFallback($lang), $vevent);
119119
$template->addFooter();
120120

121121
foreach ($emailAddresses as $emailAddress) {

apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,29 @@ public function __construct(IConfig $config,
7373
* Send push notification to all users.
7474
*
7575
* @param VEvent $vevent
76-
* @param string $calendarDisplayName
76+
* @param string|null $calendarDisplayName
7777
* @param string[] $principalEmailAddresses
7878
* @param IUser[] $users
7979
* @throws \Exception
8080
*/
8181
public function send(VEvent $vevent,
82-
string $calendarDisplayName,
82+
?string $calendarDisplayName,
8383
array $principalEmailAddresses,
8484
array $users = []):void {
8585
if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'no') !== 'yes') {
8686
return;
8787
}
8888

8989
$eventDetails = $this->extractEventDetails($vevent);
90-
$eventDetails['calendar_displayname'] = $calendarDisplayName;
9190
$eventUUID = (string) $vevent->UID;
9291
if (!$eventUUID) {
9392
return;
9493
};
9594
$eventUUIDHash = hash('sha256', $eventUUID, false);
9695

9796
foreach ($users as $user) {
97+
$eventDetails['calendar_displayname'] = $calendarDisplayName ?? $this->getCalendarDisplayNameFallback($this->l10nFactory->getUserLanguage($user));
98+
9899
/** @var INotification $notification */
99100
$notification = $this->manager->createNotification();
100101
$notification->setApp(Application::APP_ID)

0 commit comments

Comments
 (0)