Skip to content

Commit

Permalink
feat: add notes path to capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasKaminsky committed Feb 4, 2025
1 parent 9c1b57a commit e095095
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
45 changes: 25 additions & 20 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions lib/AppInfo/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@

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 {
return [
Application::APP_ID => [
'api_version' => Application::$API_VERSIONS,
'version' => $this->appManager->getAppVersion(Application::APP_ID),
'notes_path' => $this->userId ? $this->noteUtil->getNotesFolderUserPath($this->userId) : null,

Check failure on line 29 in lib/AppInfo/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable28

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:29:21: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

Check failure on line 29 in lib/AppInfo/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable29

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:29:21: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

Check failure on line 29 in lib/AppInfo/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable30

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:29:21: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

Check failure on line 29 in lib/AppInfo/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable31

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:29:21: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

Check failure on line 29 in lib/AppInfo/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:29:21: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
],
];
}
Expand Down
6 changes: 6 additions & 0 deletions lib/Service/NoteUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check failure on line 193 in lib/Service/NoteUtil.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable28

MissingDependency

lib/Service/NoteUtil.php:193:17: MissingDependency: OCP\Files\IRootFolder depends on class or interface oc\hooks\emitter that does not exist (see https://psalm.dev/157)

Check failure on line 193 in lib/Service/NoteUtil.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable29

MissingDependency

lib/Service/NoteUtil.php:193:17: MissingDependency: OCP\Files\IRootFolder depends on class or interface oc\hooks\emitter that does not exist (see https://psalm.dev/157)

Check failure on line 193 in lib/Service/NoteUtil.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable30

MissingDependency

lib/Service/NoteUtil.php:193:17: MissingDependency: OCP\Files\IRootFolder depends on class or interface oc\hooks\emitter that does not exist (see https://psalm.dev/157)

Check failure on line 193 in lib/Service/NoteUtil.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable31

MissingDependency

lib/Service/NoteUtil.php:193:17: MissingDependency: OCP\Files\IRootFolder depends on class or interface oc\hooks\emitter that does not exist (see https://psalm.dev/157)

Check failure on line 193 in lib/Service/NoteUtil.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

MissingDependency

lib/Service/NoteUtil.php:193:17: MissingDependency: OCP\Files\IRootFolder depends on class or interface oc\hooks\emitter that does not exist (see https://psalm.dev/157)
$notesPath = $this->settingsService->get($userId, 'notesPath');
Expand Down

0 comments on commit e095095

Please sign in to comment.