Files
Neon Overlord 874c25cfb7
build / build (push) Failing after 1m32s
fix: namespace the dashboard widget and reference provider IDs
Nextcloud keys dashboard widgets and reference providers globally, not per
app, so the rebrand had to cover them too and did not. This fork shipped
with upstream's IDs -- mastodon_notifications, mastodon_home_timeline and
mastodon-multi -- and enabling it alongside integration_mastodon clobbered
that app's registry entries. The dashboard then resolved those IDs to
classes in the wrong app and logged:

  Could not register lazy dashboard widget: OCA\Mastodon\Dashboard\MastodonWidget

Found on a live instance running both apps side by side. No data was
affected; disabling this app restored the other immediately.

The JS registrations in dashboard.js/dashboardHome.js are renamed to match,
since OCA.Dashboard.register() must agree with the widget's getId().

'connected-accounts' is deliberately left shared -- it is a core Nextcloud
settings section, not an app-owned identifier. 'mastodonToken' is likewise
left alone: it is a query parameter passed between this app's own controller
and its own settings page.

Assisted-by: Claude Code:claude-opus-5
2026-08-03 15:14:08 -07:00

101 lines
2.5 KiB
PHP

<?php
/**
* @copyright Copyright (c) 2020 Julien Veyssier <julien-nc@posteo.net>
*
* @author Julien Veyssier <julien-nc@posteo.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\GoToSocial\Dashboard;
use OCA\GoToSocial\AppInfo\Application;
use OCA\GoToSocial\Service\MastodonAPIService;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Services\IInitialState;
use OCP\Dashboard\IWidget;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Util;
class GoToSocialWidget implements IWidget {
public function __construct(
private IL10N $l10n,
private IAppConfig $appConfig,
private MastodonAPIService $mastodonAPIService,
private IURLGenerator $url,
private IInitialState $initialStateService,
private ?string $userId,
) {
}
/**
* @inheritDoc
*/
public function getId(): string {
return 'gotosocial_notifications';
}
/**
* @inheritDoc
*/
public function getTitle(): string {
return $this->l10n->t('GoToSocial notifications');
}
/**
* @inheritDoc
*/
public function getOrder(): int {
return 10;
}
/**
* @inheritDoc
*/
public function getIconClass(): string {
return 'icon-mastodon';
}
/**
* @inheritDoc
*/
public function getUrl(): ?string {
return $this->url->linkToRoute('settings.PersonalSettings.index', ['section' => 'connected-accounts']);
}
/**
* @inheritDoc
*/
public function load(): void {
$url = $this->mastodonAPIService->getGoToSocialUrl($this->userId);
$oauthPossible = $url !== '';
$usePopup = $this->appConfig->getAppValueString('use_popup', '0', lazy: true);
$userConfig = [
'oauth_is_possible' => $oauthPossible,
'use_popup' => ($usePopup === '1'),
'url' => $url,
];
$this->initialStateService->provideInitialState('user-config', $userConfig);
Util::addScript(Application::APP_ID, Application::APP_ID . '-dashboard');
Util::addStyle(Application::APP_ID, 'dashboard');
}
}