Skip to content

Commit e095095

Browse files
feat: add notes path to capabilities
1 parent 9c1b57a commit e095095

File tree

4 files changed

+39
-25
lines changed

4 files changed

+39
-25
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"require-dev": {
33
"guzzlehttp/guzzle": "^7",
44
"nextcloud/coding-standard": "^1.0",
5-
"nextcloud/ocp": "dev-stable28",
5+
"nextcloud/ocp": "dev-master",
66
"phan/phan": "^5",
77
"php-cs-fixer/shim": "3.66.0",
88
"psalm/phar": "^5.26",

composer.lock

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

lib/AppInfo/Capabilities.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@
99

1010
namespace OCA\Notes\AppInfo;
1111

12+
use OCA\Notes\Service\NoteUtil;
1213
use OCP\App\IAppManager;
1314
use OCP\Capabilities\ICapability;
1415

1516
class Capabilities implements ICapability {
16-
private IAppManager $appManager;
17-
18-
public function __construct(IAppManager $appManager) {
19-
$this->appManager = $appManager;
17+
public function __construct(
18+
private IAppManager $appManager,
19+
private NoteUtil $noteUtil,
20+
private ?string $userId,
21+
) {
2022
}
2123

2224
public function getCapabilities(): array {
2325
return [
2426
Application::APP_ID => [
2527
'api_version' => Application::$API_VERSIONS,
2628
'version' => $this->appManager->getAppVersion(Application::APP_ID),
29+
'notes_path' => $this->userId ? $this->noteUtil->getNotesFolderUserPath($this->userId) : null,
2730
],
2831
];
2932
}

lib/Service/NoteUtil.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ public function getOrCreateFolder(string $path, bool $create = true) : Folder {
183183
return $folder;
184184
}
185185

186+
public function getNotesFolderUserPath(string $userId): string {
187+
$userFolder = $this->getRoot()->getUserFolder($userId);
188+
$nodesFolder = $this->getOrCreateNotesFolder($userId, false);
189+
return $userFolder->getRelativePath($nodesFolder->getPath());
190+
}
191+
186192
public function getOrCreateNotesFolder(string $userId, bool $create = true) : Folder {
187193
$userFolder = $this->getRoot()->getUserFolder($userId);
188194
$notesPath = $this->settingsService->get($userId, 'notesPath');

0 commit comments

Comments
 (0)