Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions lib/Controller/GithubAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions lib/Service/GithubAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@markRead="onMarkRead">
<template #empty-content>
<NcEmptyContent v-if="emptyContentMessage"
:title="emptyContentMessage">
:name="emptyContentMessage">
<template #icon>
<component :is="emptyContentIcon" />
</template>
Expand Down Expand Up @@ -89,7 +89,6 @@ export default {
loop: null,
state: 'loading',
settingsUrl: generateUrl('/settings/user/connected-accounts'),
darkThemeColor: OCA.Accessibility?.theme === 'dark' ? '181818' : 'ffffff',
itemMenu: {
markRead: {
text: t('integration_github', 'Mark as read'),
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/Controller/GithubAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ public function testGetNotifications(): void {
$this->assertEquals($correctResult, $result->getData());
}

public function testGetNotificationsWithoutAGithubAccount(): void {
\OC::$server->get(IConfig::class)->deleteUserValue(self::TEST_USER1, self::APP_NAME, 'token');
$this->iClient->expects($this->never())->method('get');

$result = $this->githubApiController->getNotifications();

$this->assertEquals(400, $result->getStatus());
}

public function testUnsubscribeNotification(): void {
$id = 12345;

Expand Down
Loading