Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add notes path to capabilities #1468

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/AppInfo/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@

namespace OCA\Notes\AppInfo;

use OCA\Notes\Service\NoteUtil;
use OCP\App\IAppManager;
use OCP\Capabilities\ICapability;
use OCP\IUserSession;

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 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)
],
];
}
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,8 +183,14 @@
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)
$notesPath = $this->settingsService->get($userId, 'notesPath');
$allowShared = $notesPath !== $this->settingsService->getDefaultNotesPath($userId);

Expand Down
Loading