Merge pull request #41886 from nextcloud/backport/41866/stable28

[stable28] fix(dav): Prioritize timezone from core/login
This commit is contained in:
Christoph Wurst 2023-11-29 17:49:17 +01:00 committed by GitHub
commit 1b8e30ddb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 6 deletions

View file

@ -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);

View file

@ -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);