From 1ea44cc9a1432355bdbf4ffc19a8666c50bdd43f Mon Sep 17 00:00:00 2001 From: Oleksander Piskun Date: Fri, 18 Sep 2026 09:39:36 +0000 Subject: [PATCH] fix: show the content of the dashboard widget again The widget showed only its connect button to users without a GitHub account: - NcEmptyContent no longer has the title prop the message was passed in, so the message was never shown. It now uses the name prop. - /notifications requested the GitHub API without a token for such users and answered 401, so the widget reported an error. It now answers 400, which the widget already treats as not connected, without calling GitHub. darkThemeColor was not used anywhere and read OCA.Accessibility, which Nextcloud no longer provides, so it is removed. Signed-off-by: Oleksander Piskun --- CHANGELOG.md | 4 ++++ lib/Controller/GithubAPIController.php | 4 ++++ lib/Service/GithubAPIService.php | 7 +++++++ src/views/Dashboard.vue | 3 +-- tests/unit/Controller/GithubAPIControllerTest.php | 9 +++++++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fef68f2..686a4095 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). used to render issue and pull request bodies. - Update bundled JavaScript dependencies to close the remaining high-severity advisories (dompurify, js-yaml, nanoid). +- Show the message of the dashboard widget again, `NcEmptyContent` no longer has the + `title` prop it was passed in. +- Ask users who did not connect a GitHub account to connect one in the dashboard widget, + instead of reporting an error and requesting the GitHub API without a token. ## 3.2.7 - 2026-08-18 diff --git a/lib/Controller/GithubAPIController.php b/lib/Controller/GithubAPIController.php index 4bdf38b5..0e7d8a34 100644 --- a/lib/Controller/GithubAPIController.php +++ b/lib/Controller/GithubAPIController.php @@ -36,6 +36,10 @@ public function __construct( */ #[NoAdminRequired] public function getNotifications(?string $since = null): DataResponse { + if (!$this->githubAPIService->isUserConnected($this->userId)) { + // the dashboard widget shows its "connect" prompt on 400 + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } $result = $this->githubAPIService->getNotifications($this->userId, false, $since); if (isset($result['error'])) { $response = new DataResponse($result['error'], 401); diff --git a/lib/Service/GithubAPIService.php b/lib/Service/GithubAPIService.php index 12fc98b0..064c235b 100644 --- a/lib/Service/GithubAPIService.php +++ b/lib/Service/GithubAPIService.php @@ -45,6 +45,13 @@ public function __construct( $this->client = $clientService->newClient(); } + /** + * Whether the user connected a GitHub account, with OAuth or with a personal access token + */ + public function isUserConnected(string $userId): bool { + return $this->secretService->getEncryptedUserValue($userId, 'token') !== ''; + } + /** * Request an avatar image * @param string $userId diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 9bf81937..a2bc5f8e 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -13,7 +13,7 @@ @markRead="onMarkRead">