Skip to content

Commit bd8aff3

Browse files
authored
Merge branch 'master' into jtr/docs-config-mount-file-drop
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2 parents ceb1b7e + fc354f4 commit bd8aff3

81 files changed

Lines changed: 487 additions & 307 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/dav/appinfo/v1/carddav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
/** @var string $baseuri defined in remote.php */
9090
$server->setBaseUri($baseuri);
9191
// Add plugins
92-
$server->addPlugin(new MaintenancePlugin(Server::get(IConfig::class), \OCP\Server::get(IL10nFactory::class)->get('dav')));
92+
$server->addPlugin(new MaintenancePlugin(Server::get(IConfig::class), Server::get(IL10nFactory::class)->get('dav')));
9393
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));
9494
$server->addPlugin(new Plugin());
9595

apps/dav/lib/CalDAV/Federation/FederatedCalendarEntity.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use OCA\DAV\DAV\RemoteUserPrincipalBackend;
1313
use OCP\AppFramework\Db\Entity;
14+
use OCP\Constants;
1415
use OCP\DB\Types;
1516
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
1617

@@ -94,7 +95,7 @@ public function toCalendarInfo(): array {
9495
'{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $this->getSyncTokenForSabre(),
9596
'{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => $this->getSupportedCalendarComponentSet(),
9697
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->getSharedByPrincipal(),
97-
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => ($this->getPermissions() & \OCP\Constants::PERMISSION_UPDATE) === 0 ? 1 : 0,
98+
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => ($this->getPermissions() & Constants::PERMISSION_UPDATE) === 0 ? 1 : 0,
9899
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}permissions' => $this->getPermissions(),
99100
];
100101
}

apps/dav/lib/Connector/Sabre/Directory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ public function getNodeForPath($path): INode {
532532
}
533533

534534
if ($info->getMimeType() === FileInfo::MIMETYPE_FOLDER) {
535-
$node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree, $this->shareManager);
535+
$node = new Directory($this->fileView, $info, $this->tree, $this->shareManager);
536536
} else {
537537
// In case reading a directory was allowed but it turns out the node was a not a directory, reject it now.
538538
if (!$this->info->isReadable()) {

apps/dav/lib/Connector/Sabre/File.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,15 @@ public function get() {
480480
}
481481
}
482482

483+
$logger = Server::get(LoggerInterface::class);
483484
// comparing current file size with the one in DB
484485
// if different, fix DB and refresh cache.
486+
//
485487
$fsSize = $this->fileView->filesize($this->getPath());
486-
if ($this->getSize() !== $fsSize) {
487-
$logger = Server::get(LoggerInterface::class);
488+
if ($fsSize === false) {
489+
$logger->warning('file not found on storage after successfully opening it');
490+
throw new ServiceUnavailable($this->l10n->t('Failed to get size for : %1$s', [$this->getPath()]));
491+
} elseif ($this->getSize() !== $fsSize) {
488492
$logger->warning('fixing cached size of file id=' . $this->getId() . ', cached size was ' . $this->getSize() . ', but the filesystem reported a size of ' . $fsSize);
489493

490494
$this->getFileInfo()->getStorage()->getUpdater()->update($this->getFileInfo()->getInternalPath());

apps/dav/lib/Search/EventsSearchProvider.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ public function search(
150150
$formattedResults = \array_map(function (array $eventRow) use ($calendarsById, $subscriptionsById): SearchResultEntry {
151151
$component = $this->getPrimaryComponent($eventRow['calendardata'], self::$componentType);
152152
$title = (string)($component->SUMMARY ?? $this->l10n->t('Untitled event'));
153-
$subline = $this->generateSubline($component);
154153

155154
if ($eventRow['calendartype'] === CalDavBackend::CALENDAR_TYPE_CALENDAR) {
156155
$calendar = $calendarsById[$eventRow['calendarid']];
157156
} else {
158157
$calendar = $subscriptionsById[$eventRow['calendarid']];
159158
}
159+
$subline = $this->generateSubline($component, $calendar);
160160
$resourceUrl = $this->getDeepLinkToCalendarApp($calendar['principaluri'], $calendar['uri'], $eventRow['uri']);
161161
$result = new SearchResultEntry('', $title, $subline, $resourceUrl, 'icon-calendar-dark', false);
162162

@@ -204,7 +204,7 @@ protected function getDavUrlForCalendarObject(
204204
. $calendarObjectUri;
205205
}
206206

207-
protected function generateSubline(Component $eventComponent): string {
207+
protected function generateSubline(Component $eventComponent, array $calendarInfo): string {
208208
$dtStart = $eventComponent->DTSTART;
209209
$dtEnd = $this->getDTEndForEvent($eventComponent);
210210
$isAllDayEvent = $dtStart instanceof Property\ICalendar\Date;
@@ -214,24 +214,31 @@ protected function generateSubline(Component $eventComponent): string {
214214
if ($isAllDayEvent) {
215215
$endDateTime->modify('-1 day');
216216
if ($this->isDayEqual($startDateTime, $endDateTime)) {
217-
return $this->l10n->l('date', $startDateTime, ['width' => 'medium']);
217+
$formattedSubline = $this->l10n->l('date', $startDateTime, ['width' => 'medium']);
218+
} else {
219+
$formattedStart = $this->l10n->l('date', $startDateTime, ['width' => 'medium']);
220+
$formattedEnd = $this->l10n->l('date', $endDateTime, ['width' => 'medium']);
221+
$formattedSubline = "$formattedStart - $formattedEnd";
218222
}
223+
} else {
224+
$formattedStartDate = $this->l10n->l('date', $startDateTime, ['width' => 'medium']);
225+
$formattedEndDate = $this->l10n->l('date', $endDateTime, ['width' => 'medium']);
226+
$formattedStartTime = $this->l10n->l('time', $startDateTime, ['width' => 'short']);
227+
$formattedEndTime = $this->l10n->l('time', $endDateTime, ['width' => 'short']);
219228

220-
$formattedStart = $this->l10n->l('date', $startDateTime, ['width' => 'medium']);
221-
$formattedEnd = $this->l10n->l('date', $endDateTime, ['width' => 'medium']);
222-
return "$formattedStart - $formattedEnd";
229+
if ($this->isDayEqual($startDateTime, $endDateTime)) {
230+
$formattedSubline = "$formattedStartDate $formattedStartTime - $formattedEndTime";
231+
} else {
232+
$formattedSubline = "$formattedStartDate $formattedStartTime - $formattedEndDate $formattedEndTime";
233+
}
223234
}
224235

225-
$formattedStartDate = $this->l10n->l('date', $startDateTime, ['width' => 'medium']);
226-
$formattedEndDate = $this->l10n->l('date', $endDateTime, ['width' => 'medium']);
227-
$formattedStartTime = $this->l10n->l('time', $startDateTime, ['width' => 'short']);
228-
$formattedEndTime = $this->l10n->l('time', $endDateTime, ['width' => 'short']);
229-
230-
if ($this->isDayEqual($startDateTime, $endDateTime)) {
231-
return "$formattedStartDate $formattedStartTime - $formattedEndTime";
236+
if (isset($calendarInfo['{DAV:}displayname']) && !empty($calendarInfo['{DAV:}displayname'])) {
237+
$formattedSubline = $formattedSubline . " ({$calendarInfo['{DAV:}displayname']})";
232238
}
233239

234-
return "$formattedStartDate $formattedStartTime - $formattedEndDate $formattedEndTime";
240+
// string cast is just to make psalm happy
241+
return (string)$formattedSubline;
235242
}
236243

237244
protected function getDTEndForEvent(Component $eventComponent):Property {

apps/dav/lib/Search/TasksSearchProvider.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ public function search(
9696
$formattedResults = \array_map(function (array $taskRow) use ($calendarsById, $subscriptionsById):SearchResultEntry {
9797
$component = $this->getPrimaryComponent($taskRow['calendardata'], self::$componentType);
9898
$title = (string)($component->SUMMARY ?? $this->l10n->t('Untitled task'));
99-
$subline = $this->generateSubline($component);
10099

101100
if ($taskRow['calendartype'] === CalDavBackend::CALENDAR_TYPE_CALENDAR) {
102101
$calendar = $calendarsById[$taskRow['calendarid']];
103102
} else {
104103
$calendar = $subscriptionsById[$taskRow['calendarid']];
105104
}
105+
$subline = $this->generateSubline($component, $calendar);
106106
$resourceUrl = $this->getDeepLinkToTasksApp($calendar['uri'], $taskRow['uri']);
107107

108108
return new SearchResultEntry('', $title, $subline, $resourceUrl, 'icon-checkmark', false);
@@ -128,25 +128,29 @@ protected function getDeepLinkToTasksApp(
128128
);
129129
}
130130

131-
protected function generateSubline(Component $taskComponent): string {
131+
protected function generateSubline(Component $taskComponent, array $calendarInfo): string {
132132
if ($taskComponent->COMPLETED) {
133133
$completedDateTime = new \DateTime($taskComponent->COMPLETED->getDateTime()->format(\DateTimeInterface::ATOM));
134134
$formattedDate = $this->l10n->l('date', $completedDateTime, ['width' => 'medium']);
135-
return $this->l10n->t('Completed on %s', [$formattedDate]);
136-
}
137-
138-
if ($taskComponent->DUE) {
135+
$formattedSubline = $this->l10n->t('Completed on %s', [$formattedDate]);
136+
} elseif ($taskComponent->DUE) {
139137
$dueDateTime = new \DateTime($taskComponent->DUE->getDateTime()->format(\DateTimeInterface::ATOM));
140138
$formattedDate = $this->l10n->l('date', $dueDateTime, ['width' => 'medium']);
141139

142140
if ($taskComponent->DUE->hasTime()) {
143141
$formattedTime = $this->l10n->l('time', $dueDateTime, ['width' => 'short']);
144-
return $this->l10n->t('Due on %s by %s', [$formattedDate, $formattedTime]);
142+
$formattedSubline = $this->l10n->t('Due on %s by %s', [$formattedDate, $formattedTime]);
143+
} else {
144+
$formattedSubline = $this->l10n->t('Due on %s', [$formattedDate]);
145145
}
146+
} else {
147+
$formattedSubline = '';
148+
}
146149

147-
return $this->l10n->t('Due on %s', [$formattedDate]);
150+
if (isset($calendarInfo['{DAV:}displayname']) && !empty($calendarInfo['{DAV:}displayname'])) {
151+
$formattedSubline = $formattedSubline . (!empty($formattedSubline) ? ' ' : '') . "({$calendarInfo['{DAV:}displayname']})";
148152
}
149153

150-
return '';
154+
return $formattedSubline;
151155
}
152156
}

apps/dav/tests/unit/CalDAV/Schedule/IMipServiceTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use OCP\IAppConfig;
1818
use OCP\IDBConnection;
1919
use OCP\IL10N;
20+
use OCP\IUser;
2021
use OCP\IUserManager;
2122
use OCP\L10N\IFactory;
2223
use OCP\Security\ISecureRandom;
@@ -163,7 +164,7 @@ public function testGetFrom(): void {
163164

164165
public function testIsSystemUserWhenUserExists(): void {
165166
$email = 'user@example.com';
166-
$user = $this->createMock(\OCP\IUser::class);
167+
$user = $this->createMock(IUser::class);
167168

168169
$this->userManager->expects(self::once())
169170
->method('getByEmail')

apps/dav/tests/unit/Search/EventsSearchProviderTest.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public function testGetDeepLinkToCalendarApp(
436436
}
437437

438438
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'generateSublineDataProvider')]
439-
public function testGenerateSubline(string $ics, string $expectedSubline): void {
439+
public function testGenerateSubline(string $ics, string $expectedSubline, array $calendarInfo = []): void {
440440
$vCalendar = Reader::read($ics, Reader::OPTION_FORGIVING);
441441
$eventComponent = $vCalendar->VEVENT;
442442

@@ -449,19 +449,23 @@ public function testGenerateSubline(string $ics, string $expectedSubline): void
449449
return $date->format('m-d');
450450
});
451451

452-
$actual = self::invokePrivate($this->provider, 'generateSubline', [$eventComponent]);
452+
$actual = self::invokePrivate($this->provider, 'generateSubline', [$eventComponent, $calendarInfo]);
453453
$this->assertEquals($expectedSubline, $actual);
454454
}
455455

456456
public static function generateSublineDataProvider(): array {
457457
return [
458-
[self::$vEvent1, '08-16 09:00 - 10:00'],
459-
[self::$vEvent2, '08-16 09:00 - 08-17 10:00'],
460-
[self::$vEvent3, '10-05'],
461-
[self::$vEvent4, '10-05 - 10-07'],
462-
[self::$vEvent5, '10-05 - 10-09'],
463-
[self::$vEvent6, '10-05'],
464-
[self::$vEvent7, '08-16 09:00 - 09:00'],
458+
[self::$vEvent1, '08-16 09:00 - 10:00', []],
459+
[self::$vEvent2, '08-16 09:00 - 08-17 10:00', []],
460+
[self::$vEvent3, '10-05', []],
461+
[self::$vEvent4, '10-05 - 10-07', []],
462+
[self::$vEvent5, '10-05 - 10-09', []],
463+
[self::$vEvent6, '10-05', []],
464+
[self::$vEvent7, '08-16 09:00 - 09:00', []],
465+
[self::$vEvent1, '08-16 09:00 - 10:00 (My Calendar)', ['{DAV:}displayname' => 'My Calendar']],
466+
[self::$vEvent3, '10-05 (My Calendar)', ['{DAV:}displayname' => 'My Calendar']],
467+
[self::$vEvent2, '08-16 09:00 - 08-17 10:00 (My Calendar)', ['{DAV:}displayname' => 'My Calendar']],
468+
[self::$vEvent1, '08-16 09:00 - 10:00', ['{DAV:}displayname' => '']],
465469
];
466470
}
467471
}

apps/dav/tests/unit/Search/TasksSearchProviderTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,24 +290,29 @@ public function testGetDeepLinkToTasksApp(): void {
290290
}
291291

292292
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'generateSublineDataProvider')]
293-
public function testGenerateSubline(string $ics, string $expectedSubline): void {
293+
public function testGenerateSubline(string $ics, string $expectedSubline, array $calendarInfo = []): void {
294294
$vCalendar = Reader::read($ics, Reader::OPTION_FORGIVING);
295295
$taskComponent = $vCalendar->VTODO;
296296

297297
$this->l10n->method('t')->willReturnArgument(0);
298298
$this->l10n->method('l')->willReturnArgument(0);
299299

300-
$actual = self::invokePrivate($this->provider, 'generateSubline', [$taskComponent]);
300+
$actual = self::invokePrivate($this->provider, 'generateSubline', [$taskComponent, $calendarInfo]);
301301
$this->assertEquals($expectedSubline, $actual);
302302
}
303303

304304
public static function generateSublineDataProvider(): array {
305305
return [
306-
[self::$vTodo0, ''],
307-
[self::$vTodo1, 'Completed on %s'],
308-
[self::$vTodo2, 'Completed on %s'],
309-
[self::$vTodo3, 'Due on %s'],
310-
[self::$vTodo4, 'Due on %s by %s'],
306+
[self::$vTodo0, '', []],
307+
[self::$vTodo1, 'Completed on %s', []],
308+
[self::$vTodo2, 'Completed on %s', []],
309+
[self::$vTodo3, 'Due on %s', []],
310+
[self::$vTodo4, 'Due on %s by %s', []],
311+
[self::$vTodo0, '(My Tasks)', ['{DAV:}displayname' => 'My Tasks']],
312+
[self::$vTodo1, 'Completed on %s (My Tasks)', ['{DAV:}displayname' => 'My Tasks']],
313+
[self::$vTodo3, 'Due on %s (My Tasks)', ['{DAV:}displayname' => 'My Tasks']],
314+
[self::$vTodo4, 'Due on %s by %s (My Tasks)', ['{DAV:}displayname' => 'My Tasks']],
315+
[self::$vTodo1, 'Completed on %s', ['{DAV:}displayname' => '']],
311316
];
312317
}
313318
}

apps/encryption/l10n/es.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)