Files
Neon Overlord d2c70bc226 fork: rebrand as integration_gotosocial
Fork of nextcloud/integration_mastodon v5.2.0 (6a56211), AGPL-3.0, with
upstream copyright notices and CHANGELOG preserved unchanged.

Rebranded: app ID, namespace, dashboard widgets, reference provider, icon
component, search provider IDs and every user-facing string. GoToSocial
calls them posts, not toots, and its mascot is a sloth.

Deliberately NOT rebranded: MastodonAPIService, MastodonAPIController,
route names and config keys. They speak the Mastodon client API, which is
what GoToSocial implements -- renaming them would make the code claim a
protocol that does not exist, and would make this fork expensive to rebase
on future upstream releases.

Translations are inherited. Strings reworded by the rebrand fall back to
English; the rest still work in all 124 locales.

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

63 lines
2.3 KiB
PHP

<?php
namespace OCA\GoToSocial\Settings;
use OCA\GoToSocial\AppInfo\Application;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
use OCP\Security\ICrypto;
use OCP\Settings\ISettings;
class Personal implements ISettings {
public function __construct(
private IAppConfig $appConfig,
private IConfig $config,
private IInitialState $initialStateService,
private ICrypto $crypto,
private ?string $userId,
) {
}
/**
* @return TemplateResponse
*/
public function getForm(): TemplateResponse {
$token = $this->config->getUserValue($this->userId, Application::APP_ID, 'token');
$token = $token === '' ? '' : $this->crypto->decrypt($token);
$userName = $this->config->getUserValue($this->userId, Application::APP_ID, 'user_name');
$navigationEnabled = $this->config->getUserValue($this->userId, Application::APP_ID, 'navigation_enabled', '0') === '1';
$searchStatusesEnabled = $this->config->getUserValue($this->userId, Application::APP_ID, 'search_statuses_enabled', '1') === '1';
$searchAccountsEnabled = $this->config->getUserValue($this->userId, Application::APP_ID, 'search_accounts_enabled', '1') === '1';
$searchHashtagsEnabled = $this->config->getUserValue($this->userId, Application::APP_ID, 'search_hashtags_enabled', '1') === '1';
$adminOauthUrl = $this->appConfig->getAppValueString('oauth_instance_url', lazy: true);
$url = $this->config->getUserValue($this->userId, Application::APP_ID, 'url', $adminOauthUrl) ?: $adminOauthUrl;
$usePopup = $this->appConfig->getAppValueString('use_popup', '0', lazy: true);
$userConfig = [
// don't expose the token to the user
'token' => $token !== '' ? 'dummyToken' : '',
'url' => $url,
'use_popup' => ($usePopup === '1'),
'user_name' => $userName,
'navigation_enabled' => $navigationEnabled,
'search_statuses_enabled' => $searchStatusesEnabled,
'search_accounts_enabled' => $searchAccountsEnabled,
'search_hashtags_enabled' => $searchHashtagsEnabled,
];
$this->initialStateService->provideInitialState('user-config', $userConfig);
return new TemplateResponse(Application::APP_ID, 'personalSettings');
}
public function getSection(): string {
return 'connected-accounts';
}
public function getPriority(): int {
return 15;
}
}