Skip to content

Commit 15c2df6

Browse files
authored
Merge pull request #1468 from nextcloud/notesFolderToCapability
add notes path to capabilities
2 parents 8ff7e97 + 5b6a20c commit 15c2df6

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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 !== null && $this->userId !== ' ' ? $this->noteUtil->getNotesFolderUserPath($this->userId) : null,
2730
],
2831
];
2932
}

lib/Service/NoteUtil.php

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

186+
public function getNotesFolderUserPath(string $userId): ?string {
187+
/** @psalm-suppress MissingDependency */
188+
$userFolder = $this->getRoot()->getUserFolder($userId);
189+
$nodesFolder = $this->getOrCreateNotesFolder($userId, false);
190+
return $userFolder->getRelativePath($nodesFolder->getPath());
191+
}
192+
186193
public function getOrCreateNotesFolder(string $userId, bool $create = true) : Folder {
187194
$userFolder = $this->getRoot()->getUserFolder($userId);
188195
$notesPath = $this->settingsService->get($userId, 'notesPath');

0 commit comments

Comments
 (0)