aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_reminders/lib/Dav/PropFindPlugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_reminders/lib/Dav/PropFindPlugin.php')
-rw-r--r--apps/files_reminders/lib/Dav/PropFindPlugin.php46
1 files changed, 23 insertions, 23 deletions
diff --git a/apps/files_reminders/lib/Dav/PropFindPlugin.php b/apps/files_reminders/lib/Dav/PropFindPlugin.php
index e476c1a3b13..014e636eb2d 100644
--- a/apps/files_reminders/lib/Dav/PropFindPlugin.php
+++ b/apps/files_reminders/lib/Dav/PropFindPlugin.php
@@ -3,33 +3,17 @@
declare(strict_types=1);
/**
- * @copyright 2024 Christopher Ng <chrng8@gmail.com>
- *
- * @author Christopher Ng <chrng8@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\FilesReminders\Dav;
use DateTimeInterface;
+use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\Node;
use OCA\FilesReminders\Service\ReminderService;
-use OCP\AppFramework\Db\DoesNotExistException;
+use OCP\Files\Folder;
use OCP\IUser;
use OCP\IUserSession;
use Sabre\DAV\INode;
@@ -60,6 +44,15 @@ class PropFindPlugin extends ServerPlugin {
return;
}
+ if (
+ $node instanceof Directory
+ && $propFind->getDepth() > 0
+ && $propFind->getStatus(static::REMINDER_DUE_DATE_PROPERTY) !== null
+ ) {
+ $folder = $node->getNode();
+ $this->cacheFolder($folder);
+ }
+
$propFind->handle(
static::REMINDER_DUE_DATE_PROPERTY,
function () use ($node) {
@@ -69,9 +62,8 @@ class PropFindPlugin extends ServerPlugin {
}
$fileId = $node->getId();
- try {
- $reminder = $this->reminderService->getDueForUser($user, $fileId);
- } catch (DoesNotExistException $e) {
+ $reminder = $this->reminderService->getDueForUser($user, $fileId, false);
+ if ($reminder === null) {
return '';
}
@@ -79,4 +71,12 @@ class PropFindPlugin extends ServerPlugin {
},
);
}
+
+ private function cacheFolder(Folder $folder): void {
+ $user = $this->userSession->getUser();
+ if (!($user instanceof IUser)) {
+ return;
+ }
+ $this->reminderService->cacheFolder($user, $folder);
+ }
}