]> git.mxchange.org Git - friendica.git/commitdiff
Use "avatar" instead of "contact"
authorMichael <heluecht@pirati.ca>
Fri, 10 Jun 2022 20:26:57 +0000 (20:26 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 10 Jun 2022 20:26:57 +0000 (20:26 +0000)
src/Factory/Api/Mastodon/Account.php
src/Factory/Api/Mastodon/Status.php
src/Object/Api/Mastodon/Account.php

index 42351969aff414ebad020941c69bd5863450bfa0..cffd5d8924ff75a0cedde15b6485087a47254a4c 100644 (file)
@@ -76,22 +76,22 @@ class Account extends BaseFactory
         */
        public function createFromUriId(int $contactUriId, $uid = 0): \Friendica\Object\Api\Mastodon\Account
        {
-               $contact = DBA::selectFirst('account-user-view', [], ['uri-id' => $contactUriId, 'uid' => [0, $uid]], ['order' => ['id' => true]]);
-               if (empty($contact)) {
+               $avatar = DBA::selectFirst('account-user-view', [], ['uri-id' => $contactUriId, 'uid' => [0, $uid]], ['order' => ['id' => true]]);
+               if (empty($avatar)) {
                        throw new HTTPException\NotFoundException('Contact ' . $contactUriId . ' not found');
                }
 
                $fields = new Fields();
 
-               if (Contact::isLocal($contact['url'])) {
-                       $self_contact = Contact::selectFirst(['uid'], ['nurl' => $contact['nurl'], 'self' => true]);
+               if (Contact::isLocal($avatar['url'])) {
+                       $self_contact = Contact::selectFirst(['uid'], ['nurl' => $avatar['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, $contact, $fields);
+               return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $avatar, $fields);
        }
 
        /**
@@ -101,10 +101,10 @@ class Account extends BaseFactory
         */
        public function createFromUserId(int $userId): \Friendica\Object\Api\Mastodon\Account
        {
-               $contact       = DBA::selectFirst('account-user-view', [], ['uid' => $userId, 'self' => true]);
+               $avatar       = 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, $contact, $fields);
+               return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $avatar, $fields);
        }
 }
index 63dc7c4e7c287ccb01328c7ac2571e8bb08b47d8..5d58944150153f79eaf5b4500e992f5117425769 100644 (file)
@@ -78,7 +78,7 @@ class Status extends BaseFactory
         * @throws HTTPException\InternalServerErrorException
         * @throws ImagickException|HTTPException\NotFoundException
         */
-       public function createFromUriId(int $uriId, $uid = 0, $item = []): \Friendica\Object\Api\Mastodon\Status
+       public function createFromUriId(int $uriId, $uid = 0): \Friendica\Object\Api\Mastodon\Status
        {
                $fields = ['uri-id', 'uid', 'author-id', 'author-uri-id', 'author-link', 'starred', 'app', 'title', 'body', 'raw-body', 'content-warning', 'question-id',
                        'created', 'network', 'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity', 'featured', 'has-media'];
index aac23ef5ed3d24163a10c49d41ae3a0f3cca7c1f..89e3975d61c18e487ee5ded5836c63359199485d 100644 (file)
@@ -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   $contact entry of "account-user-view"
+        * @param array   $avatar entry of "account-user-view"
         * @param Fields  $fields  Profile fields
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function __construct(BaseURL $baseUrl, array $contact, Fields $fields)
+       public function __construct(BaseURL $baseUrl, array $avatar, Fields $fields)
        {
-               $this->id              = (string)$contact['pid'];
-               $this->username        = $contact['nick'];
+               $this->id              = (string)$avatar['pid'];
+               $this->username        = $avatar['nick'];
                $this->acct            =
-                       strpos($contact['url'], $baseUrl->get() . '/') === 0 ?
-                               $contact['nick'] :
-                               $contact['addr'];
-               $this->display_name    = $contact['name'];
-               $this->locked          = (bool)$contact['manually-approve'];
-               $this->bot             = ($contact['contact-type'] == Contact::TYPE_NEWS);
-               $this->discoverable    = !$contact['unsearchable'];
-               $this->group           = ($contact['contact-type'] == Contact::TYPE_COMMUNITY);
+                       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);
 
-               $this->created_at      = DateTimeFormat::utc($contact['created'] ?: DBA::NULL_DATETIME, DateTimeFormat::JSON);
+               $this->created_at      = DateTimeFormat::utc($avatar['created'] ?: DBA::NULL_DATETIME, DateTimeFormat::JSON);
 
-               $this->note            = BBCode::convertForUriId($contact['uri-id'], $contact['about'], BBCode::EXTERNAL);
-               $this->url             = $contact['url'];
-               $this->avatar          = Contact::getAvatarUrlForId($contact['id'] ?? 0 ?: $contact['pid'], Proxy::SIZE_SMALL, $contact['updated'], $contact['guid'] ?? '');
+               $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->avatar_static   = $this->avatar;
-               $this->header          = Contact::getHeaderUrlForId($contact['id'] ?? 0 ?: $contact['pid'], '', $contact['updated'], $contact['guid'] ?? '');
+               $this->header          = Contact::getHeaderUrlForId($avatar['id'] ?? 0 ?: $avatar['pid'], '', $avatar['updated'], $avatar['guid'] ?? '');
                $this->header_static   = $this->header;
-               $this->followers_count = $contact['ap-followers_count'] ?? $contact['diaspora-interacted_count'] ?? 0;
-               $this->following_count = $contact['ap-following_count'] ?? $contact['diaspora-interacting_count'] ?? 0;
-               $this->statuses_count  = $contact['ap-statuses_count'] ?? $contact['diaspora-post_count'] ?? 0;
+               $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;
 
-               $lastItem = $contact['last-item'] ?: DBA::NULL_DATETIME;
+               $lastItem = $avatar['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