diff options
Diffstat (limited to 'apps/federation/lib/Controller/SettingsController.php')
-rw-r--r-- | apps/federation/lib/Controller/SettingsController.php | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/apps/federation/lib/Controller/SettingsController.php b/apps/federation/lib/Controller/SettingsController.php index c60a7d31d7c..8abc2f8af57 100644 --- a/apps/federation/lib/Controller/SettingsController.php +++ b/apps/federation/lib/Controller/SettingsController.php @@ -31,20 +31,10 @@ use OCP\IL10N; use OCP\IRequest; class SettingsController extends Controller { + private IL10N $l; + private TrustedServers $trustedServers; - /** @var IL10N */ - private $l; - - /** @var TrustedServers */ - private $trustedServers; - - /** - * @param string $AppName - * @param IRequest $request - * @param IL10N $l10n - * @param TrustedServers $trustedServers - */ - public function __construct($AppName, + public function __construct(string $AppName, IRequest $request, IL10N $l10n, TrustedServers $trustedServers @@ -59,31 +49,25 @@ class SettingsController extends Controller { * Add server to the list of trusted Nextclouds. * * @AuthorizedAdminSetting(settings=OCA\Federation\Settings\Admin) - * @param string $url - * @return DataResponse * @throws HintException */ - public function addServer($url) { + public function addServer(string $url): DataResponse { $this->checkServer($url); $id = $this->trustedServers->addServer($url); - return new DataResponse( - [ - 'url' => $url, - 'id' => $id, - 'message' => $this->l->t('Added to the list of trusted servers') - ] - ); + return new DataResponse([ + 'url' => $url, + 'id' => $id, + 'message' => $this->l->t('Added to the list of trusted servers') + ]); } /** * Add server to the list of trusted Nextclouds. * * @AuthorizedAdminSetting(settings=OCA\Federation\Settings\Admin) - * @param int $id - * @return DataResponse */ - public function removeServer($id) { + public function removeServer(int $id): DataResponse { $this->trustedServers->removeServer($id); return new DataResponse(); } @@ -92,23 +76,19 @@ class SettingsController extends Controller { * Check if the server should be added to the list of trusted servers or not. * * @AuthorizedAdminSetting(settings=OCA\Federation\Settings\Admin) - * @param string $url - * @return bool * @throws HintException */ - protected function checkServer($url) { + protected function checkServer(string $url): void { if ($this->trustedServers->isTrustedServer($url) === true) { $message = 'Server is already in the list of trusted servers.'; $hint = $this->l->t('Server is already in the list of trusted servers.'); throw new HintException($message, $hint); } - if ($this->trustedServers->isOwnCloudServer($url) === false) { + if ($this->trustedServers->isNextcloudServer($url) === false) { $message = 'No server to federate with found'; $hint = $this->l->t('No server to federate with found'); throw new HintException($message, $hint); } - - return true; } } |