From 676ca36c52f824893738d9021985fbd9b2ff5f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Fri, 29 Jul 2022 06:30:29 +0200 Subject: [PATCH] Changes: - reformatted arrays --- src/Model/Contact.php | 33 +++++++++++++++++++----------- src/Model/User.php | 47 ++++++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index a6bb882e8..01ef3d664 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -704,22 +704,31 @@ class Contact $file_suffix = 'jpg'; - $fields = ['name' => $profile['name'], 'nick' => $user['nickname'], - 'avatar-date' => $self['avatar-date'], 'location' => Profile::formatLocation($profile), - 'about' => $profile['about'], 'keywords' => $profile['pub_keywords'], - 'contact-type' => $user['account-type'], 'prvkey' => $user['prvkey'], - 'pubkey' => $user['pubkey'], 'xmpp' => $profile['xmpp'], 'matrix' => $profile['matrix'], 'network' => Protocol::DFRN]; + $fields = [ + 'name' => $profile['name'], + 'nick' => $user['nickname'], + 'avatar-date' => $self['avatar-date'], + 'location' => Profile::formatLocation($profile), + 'about' => $profile['about'], + 'keywords' => $profile['pub_keywords'], + 'contact-type' => $user['account-type'], + 'prvkey' => $user['prvkey'], + 'pubkey' => $user['pubkey'], + 'xmpp' => $profile['xmpp'], + 'matrix' => $profile['matrix'], + 'network' => Protocol::DFRN, + 'url' => DI::baseUrl() . '/profile/' . $user['nickname'], + 'addr' => $user['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3), + 'request' => DI::baseUrl() . '/dfrn_request/' . $user['nickname'], + 'notify' => DI::baseUrl() . '/dfrn_notify/' . $user['nickname'], + 'poll' => DI::baseUrl() . '/dfrn_poll/'. $user['nickname'], + 'confirm' => DI::baseUrl() . '/dfrn_confirm/' . $user['nickname'], + 'poco' => DI::baseUrl() . '/poco/' . $user['nickname'], + ]; // it seems as if ported accounts can have wrong values, so we make sure that now everything is fine. - $fields['url'] = DI::baseUrl() . '/profile/' . $user['nickname']; $fields['nurl'] = Strings::normaliseLink($fields['url']); $fields['uri-id'] = ItemURI::getIdByURI($fields['url']); - $fields['addr'] = $user['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3); - $fields['request'] = DI::baseUrl() . '/dfrn_request/' . $user['nickname']; - $fields['notify'] = DI::baseUrl() . '/dfrn_notify/' . $user['nickname']; - $fields['poll'] = DI::baseUrl() . '/dfrn_poll/'. $user['nickname']; - $fields['confirm'] = DI::baseUrl() . '/dfrn_confirm/' . $user['nickname']; - $fields['poco'] = DI::baseUrl() . '/poco/' . $user['nickname']; $avatar = Photo::selectFirst(['resource-id', 'type'], ['uid' => $uid, 'profile' => true]); if (DBA::isResult($avatar)) { diff --git a/src/Model/User.php b/src/Model/User.php index a05d8a277..1e002aa3f 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -212,32 +212,33 @@ class User throw new Exception(DI::l10n()->t('SERIOUS ERROR: Generation of security keys failed.')); } - $system = []; - $system['uid'] = 0; - $system['created'] = DateTimeFormat::utcNow(); - $system['self'] = true; - $system['network'] = Protocol::ACTIVITYPUB; - $system['name'] = 'System Account'; - $system['addr'] = $system_actor_name . '@' . DI::baseUrl()->getHostname(); - $system['nick'] = $system_actor_name; - $system['url'] = DI::baseUrl() . '/friendica'; + $system = [ + 'uid' => 0, + 'created' => DateTimeFormat::utcNow(), + 'self' => true, + 'network' => Protocol::ACTIVITYPUB, + 'name' => 'System Account', + 'addr' => $system_actor_name . '@' . DI::baseUrl()->getHostname(), + 'nick' => $system_actor_name, + 'url' => DI::baseUrl() . '/friendica', + 'pubkey' => $keys['pubkey'], + 'prvkey' => $keys['prvkey'], + 'blocked' => 0, + 'pending' => 0, + 'contact-type' => Contact::TYPE_RELAY, // In AP this is translated to 'Application' + 'name-date' => DateTimeFormat::utcNow(), + 'uri-date' => DateTimeFormat::utcNow(), + 'avatar-date' => DateTimeFormat::utcNow(), + 'closeness' => 0, + 'baseurl' => DI::baseUrl(), + ]; $system['avatar'] = $system['photo'] = Contact::getDefaultAvatar($system, Proxy::SIZE_SMALL); - $system['thumb'] = Contact::getDefaultAvatar($system, Proxy::SIZE_THUMB); - $system['micro'] = Contact::getDefaultAvatar($system, Proxy::SIZE_MICRO); + $system['thumb'] = Contact::getDefaultAvatar($system, Proxy::SIZE_THUMB); + $system['micro'] = Contact::getDefaultAvatar($system, Proxy::SIZE_MICRO); + $system['nurl'] = Strings::normaliseLink($system['url']); + $system['gsid'] = GServer::getID($system['baseurl']); - $system['nurl'] = Strings::normaliseLink($system['url']); - $system['pubkey'] = $keys['pubkey']; - $system['prvkey'] = $keys['prvkey']; - $system['blocked'] = 0; - $system['pending'] = 0; - $system['contact-type'] = Contact::TYPE_RELAY; // In AP this is translated to 'Application' - $system['name-date'] = DateTimeFormat::utcNow(); - $system['uri-date'] = DateTimeFormat::utcNow(); - $system['avatar-date'] = DateTimeFormat::utcNow(); - $system['closeness'] = 0; - $system['baseurl'] = DI::baseUrl(); - $system['gsid'] = GServer::getID($system['baseurl']); Contact::insert($system); }