From 691e455f2621cef4c907429fa38d87019e9d1cc4 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Fri, 24 Jan 2025 14:29:52 +0100 Subject: [PATCH] feat: add notes path to capabilities --- composer.json | 2 +- composer.lock | 45 ++++++++++++++++++++---------------- lib/AppInfo/Capabilities.php | 11 +++++---- lib/Service/NoteUtil.php | 6 +++++ 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index aa15da4ff..35af49998 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "require-dev": { "guzzlehttp/guzzle": "^7", "nextcloud/coding-standard": "^1.0", - "nextcloud/ocp": "dev-stable28", + "nextcloud/ocp": "dev-master", "phan/phan": "^5", "php-cs-fixer/shim": "3.66.0", "psalm/phar": "^5.26", diff --git a/composer.lock b/composer.lock index eabf1dc60..97246cc64 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a6571c35278759d1a2fff56cfce9ca9a", + "content-hash": "b066feb68f542b675145c4ecd285012c", "packages": [], "packages-dev": [ { @@ -836,29 +836,30 @@ }, { "name": "nextcloud/ocp", - "version": "dev-stable28", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/nextcloud-deps/ocp.git", - "reference": "d1399b589aa6c0393b4f62bd7022315a711d8c09" + "reference": "df0b0d885420a4168cd1470ee33364a3369bed1c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/d1399b589aa6c0393b4f62bd7022315a711d8c09", - "reference": "d1399b589aa6c0393b4f62bd7022315a711d8c09", + "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/df0b0d885420a4168cd1470ee33364a3369bed1c", + "reference": "df0b0d885420a4168cd1470ee33364a3369bed1c", "shasum": "" }, "require": { - "php": "~8.0 || ~8.1 || ~8.2 || ~8.3", + "php": "~8.1 || ~8.2 || ~8.3 || ~8.4", "psr/clock": "^1.0", "psr/container": "^2.0.2", "psr/event-dispatcher": "^1.0", - "psr/log": "^1.1.4" + "psr/log": "^3.0.2" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-stable28": "28.0.0-dev" + "dev-master": "32.0.0-dev" } }, "notification-url": "https://packagist.org/downloads/", @@ -869,14 +870,18 @@ { "name": "Christoph Wurst", "email": "christoph@winzerhof-wurst.at" + }, + { + "name": "Joas Schilling", + "email": "coding@schilljs.com" } ], - "description": "Composer package containing Nextcloud's public API (classes, interfaces)", + "description": "Composer package containing Nextcloud's public OCP API and the unstable NCU API", "support": { "issues": "https://github.com/nextcloud-deps/ocp/issues", - "source": "https://github.com/nextcloud-deps/ocp/tree/stable28" + "source": "https://github.com/nextcloud-deps/ocp/tree/master" }, - "time": "2025-01-08T00:43:56+00:00" + "time": "2025-01-25T00:41:21+00:00" }, { "name": "phan/phan", @@ -1580,30 +1585,30 @@ }, { "name": "psr/log", - "version": "1.1.4", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", + "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1624,9 +1629,9 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/3.0.2" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2024-09-11T13:17:53+00:00" }, { "name": "ralouphie/getallheaders", diff --git a/lib/AppInfo/Capabilities.php b/lib/AppInfo/Capabilities.php index 84a5570d1..84f128000 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..2b32cd4e0 100644 --- a/lib/Service/NoteUtil.php +++ b/lib/Service/NoteUtil.php @@ -183,6 +183,12 @@ public function getOrCreateFolder(string $path, bool $create = true) : Folder { return $folder; } + public function getNotesFolderUserPath(string $userId): string { + $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');