From 9ed8479b32586f7b22671131de06d10bb522c472 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 25 Dec 2019 05:38:50 -0500 Subject: [PATCH] Rename Api\Mastodon\Account::create contact parameter to publicContact - Update Mastodon entity documentation link - Add default value for fields --- src/Api/Mastodon/Account.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Api/Mastodon/Account.php b/src/Api/Mastodon/Account.php index 18ab93be0c..2a2212482b 100644 --- a/src/Api/Mastodon/Account.php +++ b/src/Api/Mastodon/Account.php @@ -10,7 +10,7 @@ use Friendica\Util\DateTimeFormat; /** * Class Account * - * @see https://docs.joinmastodon.org/api/entities/#account + * @see https://docs.joinmastodon.org/entities/account */ class Account { @@ -54,35 +54,37 @@ class Account var $bot = null; /** - * Creates an account record from a contact record. Expects all contact table fields to be set + * Creates an account record from a public contact record. Expects all contact table fields to be set. * - * @param array $contact Full contact table record - * @param array $apcontact Full apcontact table record + * @param array $publicContact Full contact table record with uid = 0 + * @param array $apcontact Optional full apcontact table record * @return Account * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function createFromContact(array $contact, array $apcontact = []) + public static function createFromContact(array $publicContact, array $apcontact = []) { $account = new Account(); - $account->id = $contact['id']; - $account->username = $contact['nick']; - $account->acct = $contact['nick']; - $account->display_name = $contact['name']; + $account->id = $publicContact['id']; + $account->username = $publicContact['nick']; + $account->acct = $publicContact['addr']; + $account->display_name = $publicContact['name']; $account->locked = !empty($apcontact['manually-approve']); - $account->created_at = DateTimeFormat::utc($contact['created'], DateTimeFormat::ATOM); + $account->created_at = DateTimeFormat::utc($publicContact['created'], DateTimeFormat::ATOM); $account->followers_count = $apcontact['followers_count'] ?? 0; $account->following_count = $apcontact['following_count'] ?? 0; $account->statuses_count = $apcontact['statuses_count'] ?? 0; - $account->note = BBCode::convert($contact['about'], false); - $account->url = $contact['url']; - $account->avatar = $contact['avatar']; - $account->avatar_static = $contact['avatar']; + $account->note = BBCode::convert($publicContact['about'], false); + $account->url = $publicContact['url']; + $account->avatar = $publicContact['avatar']; + $account->avatar_static = $publicContact['avatar']; // No header picture in Friendica $account->header = ''; $account->header_static = ''; // No custom emojis per account in Friendica $account->emojis = []; - $account->bot = ($contact['contact-type'] == Contact::TYPE_NEWS); + // No metadata fields in Friendica + $account->fields = []; + $account->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS); return $account; } -- 2.39.5