Skip to content

Commit 1b8e30d

Browse files
Merge pull request #41886 from nextcloud/backport/41866/stable28
[stable28] fix(dav): Prioritize timezone from core/login
2 parents ec962bb + 00ba78f commit 1b8e30d

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

apps/dav/lib/CalDAV/TimezoneService.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public function __construct(private IConfig $config,
4242
}
4343

4444
public function getUserTimezone(string $userId): ?string {
45+
$fromConfig = $this->config->getUserValue(
46+
$userId,
47+
'core',
48+
'timezone',
49+
);
50+
if ($fromConfig !== '') {
51+
return $fromConfig;
52+
}
53+
4554
$availabilityPropPath = 'calendars/' . $userId . '/inbox';
4655
$availabilityProp = '{' . Plugin::NS_CALDAV . '}calendar-availability';
4756
$availabilities = $this->propertyMapper->findPropertyByPathAndName($userId, $availabilityPropPath, $availabilityProp);

apps/dav/tests/unit/CalDAV/TimezoneServiceTest.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,22 @@ protected function setUp(): void {
7878
);
7979
}
8080

81+
public function testGetUserTimezoneFromSettings(): void {
82+
$this->config->expects(self::once())
83+
->method('getUserValue')
84+
->with('test123', 'core', 'timezone', '')
85+
->willReturn('Europe/Warsaw');
86+
87+
$timezone = $this->service->getUserTimezone('test123');
88+
89+
self::assertSame('Europe/Warsaw', $timezone);
90+
}
91+
8192
public function testGetUserTimezoneFromAvailability(): void {
93+
$this->config->expects(self::once())
94+
->method('getUserValue')
95+
->with('test123', 'core', 'timezone', '')
96+
->willReturn('');
8297
$property = new Property();
8398
$property->setPropertyvalue('BEGIN:VCALENDAR
8499
PRODID:Nextcloud DAV app
@@ -99,10 +114,12 @@ public function testGetUserTimezoneFromAvailability(): void {
99114
}
100115

101116
public function testGetUserTimezoneFromPersonalCalendar(): void {
102-
$this->config->expects(self::once())
117+
$this->config->expects(self::exactly(2))
103118
->method('getUserValue')
104-
->with('test123', 'dav', 'defaultCalendar')
105-
->willReturn('personal-1');
119+
->willReturnMap([
120+
['test123', 'core', 'timezone', '', ''],
121+
['test123', 'dav', 'defaultCalendar', '', 'personal-1'],
122+
]);
106123
$other = $this->createMock(ICalendar::class);
107124
$other->method('getUri')->willReturn('other');
108125
$personal = $this->createMock(CalendarImpl::class);
@@ -126,10 +143,12 @@ public function testGetUserTimezoneFromPersonalCalendar(): void {
126143
}
127144

128145
public function testGetUserTimezoneFromAny(): void {
129-
$this->config->expects(self::once())
146+
$this->config->expects(self::exactly(2))
130147
->method('getUserValue')
131-
->with('test123', 'dav', 'defaultCalendar')
132-
->willReturn('personal-1');
148+
->willReturnMap([
149+
['test123', 'core', 'timezone', '', ''],
150+
['test123', 'dav', 'defaultCalendar', '', 'personal-1'],
151+
]);
133152
$other = $this->createMock(ICalendar::class);
134153
$other->method('getUri')->willReturn('other');
135154
$personal = $this->createMock(CalendarImpl::class);

0 commit comments

Comments
 (0)