Skip to content

Commit

Permalink
fixup! add notes path to capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored and tobiasKaminsky committed Feb 3, 2025
1 parent ebc02c8 commit 8113c57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/AppInfo/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
use OCP\IUserSession;

class Capabilities implements ICapability {
public function __construct(private IAppManager $appManager,
private NoteUtil $noteUtil,
private IUserSession $userSession) {
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->noteUtil->getOrCreateNotesFolder($this->userSession->getUser()->getUID())->getInternalPath()
'notes_path' => $this->userId ? $this->noteUtil->getNotesFolderUserPath($this->userId) : null,

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

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable28

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:30: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 30 in lib/AppInfo/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable29

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:30: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 30 in lib/AppInfo/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable30

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:30: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 30 in lib/AppInfo/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable31

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:30: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 30 in lib/AppInfo/Capabilities.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

RiskyTruthyFalsyComparison

lib/AppInfo/Capabilities.php:30: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 8113c57

Please sign in to comment.