From fdaf0c9f93a0bce4787feff3832192bb09f19b82 Mon Sep 17 00:00:00 2001 From: Hamza Date: Tue, 23 Jun 2026 18:30:37 +0200 Subject: [PATCH] refactor: migrate AdminSettings off deprecated IInitialStateService Use OCP\AppFramework\Services\IInitialState instead of the deprecated OCP\IInitialStateService; the app-scoped API drops the APP_ID argument. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Hamza --- lib/Settings/AdminSettings.php | 20 +++----------------- tests/Unit/Settings/AdminSettingsTest.php | 14 -------------- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/lib/Settings/AdminSettings.php b/lib/Settings/AdminSettings.php index 32e8c004a7..96e8c312a3 100644 --- a/lib/Settings/AdminSettings.php +++ b/lib/Settings/AdminSettings.php @@ -17,15 +17,15 @@ use OCA\Mail\Service\Classification\ClassificationSettingsService; use OCA\Mail\Service\Provisioning\Manager as ProvisioningManager; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\Defaults; use OCP\IConfig; -use OCP\IInitialStateService; use OCP\Settings\ISettings; use OCP\TextProcessing\FreePromptTaskType; use OCP\TextProcessing\SummaryTaskType; class AdminSettings implements ISettings { - /** @var IInitialStateService */ + /** @var IInitialState */ private $initialStateService; /** @var ProvisioningManager */ @@ -40,7 +40,7 @@ class AdminSettings implements ISettings { private AiIntegrationsService $aiIntegrationsService; public function __construct( - IInitialStateService $initialStateService, + IInitialState $initialStateService, ProvisioningManager $provisioningManager, AntiSpamService $antiSpamService, GoogleIntegration $googleIntegration, @@ -62,13 +62,11 @@ public function __construct( #[\Override] public function getForm() { $this->initialStateService->provideInitialState( - Application::APP_ID, 'provisioning_settings', $this->provisioningManager->getConfigs() ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'antispam_setting', [ 'spam' => $this->antiSpamService->getSpamEmail(), @@ -77,67 +75,55 @@ public function getForm() { ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'allow_new_mail_accounts', $this->config->getAppValue('mail', 'allow_new_mail_accounts', 'yes') === 'yes' ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'layout_message_view', $this->config->getAppValue('mail', 'layout_message_view', 'threaded') ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'llm_processing', $this->aiIntegrationsService->isLlmProcessingEnabled(), ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'enabled_llm_free_prompt_backend', $this->aiIntegrationsService->isLlmAvailable(FreePromptTaskType::class) ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'enabled_llm_summary_backend', $this->aiIntegrationsService->isLlmAvailable(SummaryTaskType::class) ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'google_oauth_client_id', $this->googleIntegration->getClientId(), ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'google_oauth_redirect_url', $this->googleIntegration->getRedirectUrl(), ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'importance_classification_default', $this->classificationSettingsService->isClassificationEnabledByDefault(), ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'microsoft_oauth_tenant_id', $this->microsoftIntegration->getTenantId(), ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'microsoft_oauth_client_id', $this->microsoftIntegration->getClientId(), ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'microsoft_oauth_redirect_url', $this->microsoftIntegration->getRedirectUrl(), ); $this->initialStateService->provideInitialState( - Application::APP_ID, 'microsoft_oauth_docs', $this->themingDefaults->buildDocLinkToKey('admin-groupware-oauth-microsoft'), ); diff --git a/tests/Unit/Settings/AdminSettingsTest.php b/tests/Unit/Settings/AdminSettingsTest.php index b53df84efc..cc95185ebb 100644 --- a/tests/Unit/Settings/AdminSettingsTest.php +++ b/tests/Unit/Settings/AdminSettingsTest.php @@ -41,72 +41,58 @@ public function testGetForm() { ->method('provideInitialState') ->withConsecutive( [ - Application::APP_ID, 'provisioning_settings', $this->anything() ], [ - Application::APP_ID, 'antispam_setting', $this->anything() ], [ - Application::APP_ID, 'allow_new_mail_accounts', $this->anything() ], [ - Application::APP_ID, 'layout_message_view', $this->anything() ], [ - Application::APP_ID, 'llm_processing', $this->anything() ], [ - Application::APP_ID, 'enabled_llm_free_prompt_backend', $this->anything() ], [ - Application::APP_ID, 'enabled_llm_summary_backend', $this->anything() ], [ - Application::APP_ID, 'google_oauth_client_id', $this->anything() ], [ - Application::APP_ID, 'google_oauth_redirect_url', $this->anything() ], [ - Application::APP_ID, 'importance_classification_default', $this->anything() ], [ - Application::APP_ID, 'microsoft_oauth_tenant_id', $this->anything() ], [ - Application::APP_ID, 'microsoft_oauth_client_id', $this->anything() ], [ - Application::APP_ID, 'microsoft_oauth_redirect_url', $this->anything() ], [ - Application::APP_ID, 'microsoft_oauth_docs', $this->anything() ],