From 4157f816f5bbc3721a5b2054a7aef29827544685 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 10 Jun 2022 20:32:21 +0000 Subject: [PATCH] Fix for account variable name --- src/Factory/Api/Mastodon/Account.php | 14 +++++----- src/Object/Api/Mastodon/Account.php | 42 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Factory/Api/Mastodon/Account.php b/src/Factory/Api/Mastodon/Account.php index cffd5d8924..d0c654fc21 100644 --- a/src/Factory/Api/Mastodon/Account.php +++ b/src/Factory/Api/Mastodon/Account.php @@ -76,22 +76,22 @@ class Account extends BaseFactory */ public function createFromUriId(int $contactUriId, $uid = 0): \Friendica\Object\Api\Mastodon\Account { - $avatar = DBA::selectFirst('account-user-view', [], ['uri-id' => $contactUriId, 'uid' => [0, $uid]], ['order' => ['id' => true]]); - if (empty($avatar)) { + $account = DBA::selectFirst('account-user-view', [], ['uri-id' => $contactUriId, 'uid' => [0, $uid]], ['order' => ['id' => true]]); + if (empty($account)) { throw new HTTPException\NotFoundException('Contact ' . $contactUriId . ' not found'); } $fields = new Fields(); - if (Contact::isLocal($avatar['url'])) { - $self_contact = Contact::selectFirst(['uid'], ['nurl' => $avatar['nurl'], 'self' => true]); + if (Contact::isLocal($account['url'])) { + $self_contact = Contact::selectFirst(['uid'], ['nurl' => $account['nurl'], 'self' => true]); if (!empty($self_contact['uid'])) { $profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($self_contact['uid']); $fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields); } } - return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $avatar, $fields); + return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $account, $fields); } /** @@ -101,10 +101,10 @@ class Account extends BaseFactory */ public function createFromUserId(int $userId): \Friendica\Object\Api\Mastodon\Account { - $avatar = DBA::selectFirst('account-user-view', [], ['uid' => $userId, 'self' => true]); + $account = DBA::selectFirst('account-user-view', [], ['uid' => $userId, 'self' => true]); $profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($userId); $fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields); - return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $avatar, $fields); + return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $account, $fields); } } diff --git a/src/Object/Api/Mastodon/Account.php b/src/Object/Api/Mastodon/Account.php index 89e3975d61..3369a18c00 100644 --- a/src/Object/Api/Mastodon/Account.php +++ b/src/Object/Api/Mastodon/Account.php @@ -86,37 +86,37 @@ class Account extends BaseDataTransferObject * Creates an account record from a public contact record. Expects all contact table fields to be set. * * @param BaseURL $baseUrl - * @param array $avatar entry of "account-user-view" + * @param array $account entry of "account-user-view" * @param Fields $fields Profile fields * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function __construct(BaseURL $baseUrl, array $avatar, Fields $fields) + public function __construct(BaseURL $baseUrl, array $account, Fields $fields) { - $this->id = (string)$avatar['pid']; - $this->username = $avatar['nick']; + $this->id = (string)$account['pid']; + $this->username = $account['nick']; $this->acct = - strpos($avatar['url'], $baseUrl->get() . '/') === 0 ? - $avatar['nick'] : - $avatar['addr']; - $this->display_name = $avatar['name']; - $this->locked = (bool)$avatar['manually-approve']; - $this->bot = ($avatar['contact-type'] == Contact::TYPE_NEWS); - $this->discoverable = !$avatar['unsearchable']; - $this->group = ($avatar['contact-type'] == Contact::TYPE_COMMUNITY); + strpos($account['url'], $baseUrl->get() . '/') === 0 ? + $account['nick'] : + $account['addr']; + $this->display_name = $account['name']; + $this->locked = (bool)$account['manually-approve']; + $this->bot = ($account['contact-type'] == Contact::TYPE_NEWS); + $this->discoverable = !$account['unsearchable']; + $this->group = ($account['contact-type'] == Contact::TYPE_COMMUNITY); - $this->created_at = DateTimeFormat::utc($avatar['created'] ?: DBA::NULL_DATETIME, DateTimeFormat::JSON); + $this->created_at = DateTimeFormat::utc($account['created'] ?: DBA::NULL_DATETIME, DateTimeFormat::JSON); - $this->note = BBCode::convertForUriId($avatar['uri-id'], $avatar['about'], BBCode::EXTERNAL); - $this->url = $avatar['url']; - $this->avatar = Contact::getAvatarUrlForId($avatar['id'] ?? 0 ?: $avatar['pid'], Proxy::SIZE_SMALL, $avatar['updated'], $avatar['guid'] ?? ''); + $this->note = BBCode::convertForUriId($account['uri-id'], $account['about'], BBCode::EXTERNAL); + $this->url = $account['url']; + $this->avatar = Contact::getAvatarUrlForId($account['id'] ?? 0 ?: $account['pid'], Proxy::SIZE_SMALL, $account['updated'], $account['guid'] ?? ''); $this->avatar_static = $this->avatar; - $this->header = Contact::getHeaderUrlForId($avatar['id'] ?? 0 ?: $avatar['pid'], '', $avatar['updated'], $avatar['guid'] ?? ''); + $this->header = Contact::getHeaderUrlForId($account['id'] ?? 0 ?: $account['pid'], '', $account['updated'], $account['guid'] ?? ''); $this->header_static = $this->header; - $this->followers_count = $avatar['ap-followers_count'] ?? $avatar['diaspora-interacted_count'] ?? 0; - $this->following_count = $avatar['ap-following_count'] ?? $avatar['diaspora-interacting_count'] ?? 0; - $this->statuses_count = $avatar['ap-statuses_count'] ?? $avatar['diaspora-post_count'] ?? 0; + $this->followers_count = $account['ap-followers_count'] ?? $account['diaspora-interacted_count'] ?? 0; + $this->following_count = $account['ap-following_count'] ?? $account['diaspora-interacting_count'] ?? 0; + $this->statuses_count = $account['ap-statuses_count'] ?? $account['diaspora-post_count'] ?? 0; - $lastItem = $avatar['last-item'] ?: DBA::NULL_DATETIME; + $lastItem = $account['last-item'] ?: DBA::NULL_DATETIME; $this->last_status_at = $lastItem != DBA::NULL_DATETIME ? DateTimeFormat::utc($lastItem, 'Y-m-d') : null; // No custom emojis per account in Friendica -- 2.39.5