From: Christoph Wurst Date: Wed, 29 Nov 2023 11:17:30 +0000 (+0100) Subject: fix(dav): Prioritize timezone from core/login X-Git-Tag: v29.0.0beta1~758^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8b38d494373a0d52a8f4c4ea159fb36eddc9af6d;p=nextcloud-server.git fix(dav): Prioritize timezone from core/login Signed-off-by: Christoph Wurst --- diff --git a/apps/dav/lib/CalDAV/TimezoneService.php b/apps/dav/lib/CalDAV/TimezoneService.php index bdbd0b9fe2c..1b8855a7215 100644 --- a/apps/dav/lib/CalDAV/TimezoneService.php +++ b/apps/dav/lib/CalDAV/TimezoneService.php @@ -42,6 +42,15 @@ class TimezoneService { } public function getUserTimezone(string $userId): ?string { + $fromConfig = $this->config->getUserValue( + $userId, + 'core', + 'timezone', + ); + if ($fromConfig !== '') { + return $fromConfig; + } + $availabilityPropPath = 'calendars/' . $userId . '/inbox'; $availabilityProp = '{' . Plugin::NS_CALDAV . '}calendar-availability'; $availabilities = $this->propertyMapper->findPropertyByPathAndName($userId, $availabilityPropPath, $availabilityProp); diff --git a/apps/dav/tests/unit/CalDAV/TimezoneServiceTest.php b/apps/dav/tests/unit/CalDAV/TimezoneServiceTest.php index 3646461dc42..78f27a6c064 100644 --- a/apps/dav/tests/unit/CalDAV/TimezoneServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/TimezoneServiceTest.php @@ -78,7 +78,22 @@ class TimezoneServiceTest extends TestCase { ); } + public function testGetUserTimezoneFromSettings(): void { + $this->config->expects(self::once()) + ->method('getUserValue') + ->with('test123', 'core', 'timezone', '') + ->willReturn('Europe/Warsaw'); + + $timezone = $this->service->getUserTimezone('test123'); + + self::assertSame('Europe/Warsaw', $timezone); + } + public function testGetUserTimezoneFromAvailability(): void { + $this->config->expects(self::once()) + ->method('getUserValue') + ->with('test123', 'core', 'timezone', '') + ->willReturn(''); $property = new Property(); $property->setPropertyvalue('BEGIN:VCALENDAR PRODID:Nextcloud DAV app @@ -99,10 +114,12 @@ END:VCALENDAR'); } public function testGetUserTimezoneFromPersonalCalendar(): void { - $this->config->expects(self::once()) + $this->config->expects(self::exactly(2)) ->method('getUserValue') - ->with('test123', 'dav', 'defaultCalendar') - ->willReturn('personal-1'); + ->willReturnMap([ + ['test123', 'core', 'timezone', '', ''], + ['test123', 'dav', 'defaultCalendar', '', 'personal-1'], + ]); $other = $this->createMock(ICalendar::class); $other->method('getUri')->willReturn('other'); $personal = $this->createMock(CalendarImpl::class); @@ -126,10 +143,12 @@ END:VCALENDAR'); } public function testGetUserTimezoneFromAny(): void { - $this->config->expects(self::once()) + $this->config->expects(self::exactly(2)) ->method('getUserValue') - ->with('test123', 'dav', 'defaultCalendar') - ->willReturn('personal-1'); + ->willReturnMap([ + ['test123', 'core', 'timezone', '', ''], + ['test123', 'dav', 'defaultCalendar', '', 'personal-1'], + ]); $other = $this->createMock(ICalendar::class); $other->method('getUri')->willReturn('other'); $personal = $this->createMock(CalendarImpl::class);