From b3698e1bdd2c297dcab08a8307f403bd732a8c41 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 19 Aug 2024 17:27:01 +0200 Subject: [PATCH] fix(caldav): allow renaming of birthday calendars Signed-off-by: Anna Larch --- apps/dav/lib/CalDAV/Calendar.php | 2 +- apps/dav/tests/unit/CalDAV/CalendarTest.php | 2 ++ apps/dav/tests/unit/Command/DeleteCalendarTest.php | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php index eaf8d227a6f..2781dbafa67 100644 --- a/apps/dav/lib/CalDAV/Calendar.php +++ b/apps/dav/lib/CalDAV/Calendar.php @@ -46,7 +46,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable parent::__construct($caldavBackend, $calendarInfo); - if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) { + if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI && strcasecmp($this->calendarInfo['{DAV:}displayname'], 'Contact birthdays') === 0) { $this->calendarInfo['{DAV:}displayname'] = $l10n->t('Contact birthdays'); } if ($this->getName() === CalDavBackend::PERSONAL_CALENDAR_URI && diff --git a/apps/dav/tests/unit/CalDAV/CalendarTest.php b/apps/dav/tests/unit/CalDAV/CalendarTest.php index ca6b3191df4..ace2f808615 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarTest.php @@ -113,6 +113,7 @@ class CalendarTest extends TestCase { 'principaluri' => 'principals/users/user1', 'id' => 666, 'uri' => 'contact_birthdays', + '{DAV:}displayname' => 'Test', ]; $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); @@ -182,6 +183,7 @@ class CalendarTest extends TestCase { 'id' => 666, 'uri' => $uri ]; + $calendarInfo['{DAV:}displayname'] = 'Test'; if (!is_null($readOnlyValue)) { $calendarInfo['{http://owncloud.org/ns}read-only'] = $readOnlyValue; } diff --git a/apps/dav/tests/unit/Command/DeleteCalendarTest.php b/apps/dav/tests/unit/Command/DeleteCalendarTest.php index 3e3095a7bce..583673c9d30 100644 --- a/apps/dav/tests/unit/Command/DeleteCalendarTest.php +++ b/apps/dav/tests/unit/Command/DeleteCalendarTest.php @@ -126,7 +126,7 @@ class DeleteCalendarTest extends TestCase { $calendar = [ 'id' => $id, 'principaluri' => 'principals/users/' . self::USER, - 'uri' => self::NAME + 'uri' => self::NAME, ]; $this->userManager->expects($this->once()) @@ -187,7 +187,8 @@ class DeleteCalendarTest extends TestCase { $calendar = [ 'id' => $id, 'principaluri' => 'principals/users/' . self::USER, - 'uri' => BirthdayService::BIRTHDAY_CALENDAR_URI + 'uri' => BirthdayService::BIRTHDAY_CALENDAR_URI, + '{DAV:}displayname' => 'Test', ]; $this->userManager->expects($this->once()) @@ -216,7 +217,8 @@ class DeleteCalendarTest extends TestCase { $calendar = [ 'id' => 1234, 'principaluri' => 'principals/users/' . self::USER, - 'uri' => BirthdayService::BIRTHDAY_CALENDAR_URI + 'uri' => BirthdayService::BIRTHDAY_CALENDAR_URI, + '{DAV:}displayname' => 'Test', ]; $this->userManager->expects($this->once()) ->method('userExists') -- 2.39.5