Use "getActorName"

This commit is contained in:
Michael 2020-08-22 18:52:37 +00:00
parent 6d9302fbe4
commit b12a2c486e
3 changed files with 11 additions and 14 deletions

View file

@ -102,7 +102,7 @@ class User
/** /**
* Fetch the system account * Fetch the system account
* *
* @return return system account * @return array system account
*/ */
public static function getSystemAccount() public static function getSystemAccount()
{ {
@ -128,12 +128,9 @@ class User
*/ */
private static function createSystemAccount() private static function createSystemAccount()
{ {
$system_actor_name = DI::config()->get('system', 'actor_name'); $system_actor_name = self::getActorName();
if (empty($system_actor_name)) { if (empty($system_actor_name)) {
$system_actor_name = self::getActorName(); return;
if (empty($system_actor_name)) {
return;
}
} }
$keys = Crypto::newKeypair(4096); $keys = Crypto::newKeypair(4096);
@ -176,6 +173,11 @@ class User
*/ */
public static function getActorName() 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 // List of possible actor names
$possible_accounts = ['friendica', 'actor', 'system', 'internal']; $possible_accounts = ['friendica', 'actor', 'system', 'internal'];
foreach ($possible_accounts as $name) { foreach ($possible_accounts as $name) {
@ -686,7 +688,7 @@ class User
} }
// Add the name of the internal actor to the "forbidden" list // 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)) { if (!empty($actor_name)) {
$forbidden[] = $actor_name; $forbidden[] = $actor_name;
} }

View file

@ -513,11 +513,6 @@ class Site extends BaseAdmin
get_temppath(); get_temppath();
get_itemcachepath(); get_itemcachepath();
$system_actor_name = DI::config()->get('system', 'actor_name');
if (empty($system_actor_name)) {
$system_actor_name = User::getActorName();
}
/* Register policy */ /* Register policy */
$register_choices = [ $register_choices = [
Register::CLOSED => DI::l10n()->t('Closed'), Register::CLOSED => DI::l10n()->t('Closed'),
@ -608,7 +603,7 @@ class Site extends BaseAdmin
// name, label, value, help string, extra data... // name, label, value, help string, extra data...
'$sitename' => ['sitename', DI::l10n()->t('Site name'), DI::config()->get('config', 'sitename'), ''], '$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'], '$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, ''], '$banner' => ['banner', DI::l10n()->t('Banner/Logo'), $banner, ''],
'$email_banner' => ['email_banner', DI::l10n()->t('Email Banner/Logo'), $email_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.')], '$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.')],

View file

@ -78,7 +78,7 @@ class Xrd extends BaseModule
$name = substr($local, 0, strpos($local, '@')); $name = substr($local, 0, strpos($local, '@'));
} }
if ($name == DI::config()->get('system', 'actor_name')) { if ($name == User::getActorName()) {
$owner = User::getSystemAccount(); $owner = User::getSystemAccount();
if (empty($owner)) { if (empty($owner)) {
throw new \Friendica\Network\HTTPException\NotFoundException(); throw new \Friendica\Network\HTTPException\NotFoundException();