From b12a2c486e689e2d780f67f7d017e07bb8c67feb Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 22 Aug 2020 18:52:37 +0000 Subject: [PATCH] Use "getActorName" --- src/Model/User.php | 16 +++++++++------- src/Module/Admin/Site.php | 7 +------ src/Module/Xrd.php | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Model/User.php b/src/Model/User.php index fe20857b95..2a954e6e60 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -102,7 +102,7 @@ class User /** * Fetch the system account * - * @return return system account + * @return array system account */ public static function getSystemAccount() { @@ -128,12 +128,9 @@ class User */ private static function createSystemAccount() { - $system_actor_name = DI::config()->get('system', 'actor_name'); + $system_actor_name = self::getActorName(); if (empty($system_actor_name)) { - $system_actor_name = self::getActorName(); - if (empty($system_actor_name)) { - return; - } + return; } $keys = Crypto::newKeypair(4096); @@ -176,6 +173,11 @@ class User */ public static function getActorName() { + $system_actor_name = DI::config()->get('system', 'actor_name'); + if (!empty($system_actor_name)) { + return $system_actor_name; + } + // List of possible actor names $possible_accounts = ['friendica', 'actor', 'system', 'internal']; foreach ($possible_accounts as $name) { @@ -686,7 +688,7 @@ class User } // Add the name of the internal actor to the "forbidden" list - $actor_name = DI::config()->get('system', 'actor_name'); + $actor_name = self::getActorName(); if (!empty($actor_name)) { $forbidden[] = $actor_name; } diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 7033f09b9c..64b9395dad 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -513,11 +513,6 @@ class Site extends BaseAdmin get_temppath(); get_itemcachepath(); - $system_actor_name = DI::config()->get('system', 'actor_name'); - if (empty($system_actor_name)) { - $system_actor_name = User::getActorName(); - } - /* Register policy */ $register_choices = [ Register::CLOSED => DI::l10n()->t('Closed'), @@ -608,7 +603,7 @@ class Site extends BaseAdmin // name, label, value, help string, extra data... '$sitename' => ['sitename', DI::l10n()->t('Site name'), DI::config()->get('config', 'sitename'), ''], '$sender_email' => ['sender_email', DI::l10n()->t('Sender Email'), DI::config()->get('config', 'sender_email'), DI::l10n()->t('The email address your server shall use to send notification emails from.'), '', '', 'email'], - '$system_actor_name' => ['system_actor_name', DI::l10n()->t('Name of the system actor'), $system_actor_name, DI::l10n()->t("Name of the internal system account that is used to perform ActivityPub requests. This must be an unused username. If set, this shouldn't be changed again.")], + '$system_actor_name' => ['system_actor_name', DI::l10n()->t('Name of the system actor'), User::getActorName(), DI::l10n()->t("Name of the internal system account that is used to perform ActivityPub requests. This must be an unused username. If set, this shouldn't be changed again.")], '$banner' => ['banner', DI::l10n()->t('Banner/Logo'), $banner, ''], '$email_banner' => ['email_banner', DI::l10n()->t('Email Banner/Logo'), $email_banner, ''], '$shortcut_icon' => ['shortcut_icon', DI::l10n()->t('Shortcut icon'), DI::config()->get('system', 'shortcut_icon'), DI::l10n()->t('Link to an icon that will be used for browsers.')], diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 87adef5cfc..be6a3bf9c5 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -78,7 +78,7 @@ class Xrd extends BaseModule $name = substr($local, 0, strpos($local, '@')); } - if ($name == DI::config()->get('system', 'actor_name')) { + if ($name == User::getActorName()) { $owner = User::getSystemAccount(); if (empty($owner)) { throw new \Friendica\Network\HTTPException\NotFoundException();