diff --git a/lib/AppInfo/Capabilities.php b/lib/AppInfo/Capabilities.php index 84a5570d1..c08327657 100644 --- a/lib/AppInfo/Capabilities.php +++ b/lib/AppInfo/Capabilities.php @@ -9,14 +9,16 @@ namespace OCA\Notes\AppInfo; +use OCA\Notes\Service\NoteUtil; use OCP\App\IAppManager; use OCP\Capabilities\ICapability; class Capabilities implements ICapability { - private IAppManager $appManager; - - public function __construct(IAppManager $appManager) { - $this->appManager = $appManager; + public function __construct( + private IAppManager $appManager, + private NoteUtil $noteUtil, + private ?string $userId, + ) { } public function getCapabilities(): array { @@ -24,6 +26,7 @@ public function getCapabilities(): array { Application::APP_ID => [ 'api_version' => Application::$API_VERSIONS, 'version' => $this->appManager->getAppVersion(Application::APP_ID), + 'notes_path' => $this->userId !== null && $this->userId !== ' ' ? $this->noteUtil->getNotesFolderUserPath($this->userId) : null, ], ]; } diff --git a/lib/Service/NoteUtil.php b/lib/Service/NoteUtil.php index a99ea5c03..6cb52711b 100644 --- a/lib/Service/NoteUtil.php +++ b/lib/Service/NoteUtil.php @@ -183,6 +183,13 @@ public function getOrCreateFolder(string $path, bool $create = true) : Folder { return $folder; } + public function getNotesFolderUserPath(string $userId): ?string { + /** @psalm-suppress MissingDependency */ + $userFolder = $this->getRoot()->getUserFolder($userId); + $nodesFolder = $this->getOrCreateNotesFolder($userId, false); + return $userFolder->getRelativePath($nodesFolder->getPath()); + } + public function getOrCreateNotesFolder(string $userId, bool $create = true) : Folder { $userFolder = $this->getRoot()->getUserFolder($userId); $notesPath = $this->settingsService->get($userId, 'notesPath');