]> git.mxchange.org Git - friendica.git/commitdiff
Use account-user-view entry to instantiate Api\Mastodon\FollowRequest objects
authorHypolite Petovan <hypolite@mrpetovan.com>
Fri, 16 Dec 2022 15:29:20 +0000 (10:29 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 18 Dec 2022 06:03:37 +0000 (01:03 -0500)
- Address https://github.com/friendica/friendica/issues/11993#issuecomment-1354395861

src/Contact/Introduction/Entity/Introduction.php
src/Factory/Api/Mastodon/FollowRequest.php
src/Object/Api/Mastodon/FollowRequest.php

index 17a0bce26500dc9975e516dec33be8eb0fdffd34..40a3078a3e04ec0f9ffb5b90cb6d259087b83307 100644 (file)
@@ -25,7 +25,7 @@ use Friendica\BaseEntity;
 
 /**
  * @property-read int $uid
- * @property-read int $cid
+ * @property-read int $cid Either a public contact id (DFRN suggestion) or user-specific id (Contact::addRelationship)
  * @property-read int|null $sid
  * @property-read bool $knowyou
  * @property-read string $note
index 1a6babd312a1e650f8c564ed372171e767f6a5d7..53c78373e51324896c3dfa1e5c53aad617a5702e 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Factory\Api\Mastodon;
 use Friendica\App\BaseURL;
 use Friendica\BaseFactory;
 use Friendica\Contact\Introduction\Entity\Introduction;
+use Friendica\Database\DBA;
 use Friendica\Model\APContact;
 use Friendica\Model\Contact;
 use Friendica\Network\HTTPException;
@@ -49,18 +50,12 @@ class FollowRequest extends BaseFactory
         */
        public function createFromIntroduction(Introduction $introduction): \Friendica\Object\Api\Mastodon\FollowRequest
        {
-               $cdata = Contact::getPublicAndUserContactID($introduction->cid, $introduction->uid);
-
-               if (empty($cdata)) {
+               $account = DBA::selectFirst('account-user-view', [], ['id' => $introduction->cid, 'uid' => [0, $introduction->uid]]);
+               if (empty($account)) {
                        $this->logger->warning('Wrong introduction data', ['Introduction' => $introduction]);
                        throw new HTTPException\InternalServerErrorException('Wrong introduction data');
                }
 
-               $publicContact = Contact::getById($cdata['public']);
-               $userContact   = Contact::getById($cdata['user']);
-
-               $apContact = APContact::getByURL($publicContact['url'], false);
-
-               return new \Friendica\Object\Api\Mastodon\FollowRequest($this->baseUrl, $introduction->id, $publicContact, $apContact, $userContact);
+               return new \Friendica\Object\Api\Mastodon\FollowRequest($this->baseUrl, $introduction->id, $account);
        }
 }
index 3a634d46e0e4f1e004f74a7b0fddb3c9566b700b..0f8c9b39c0bb3fc5234029d05083ef85df6e23c5 100644 (file)
@@ -37,14 +37,12 @@ class FollowRequest extends Account
         *
         * @param BaseURL $baseUrl
         * @param int     $introduction_id Introduction record id
-        * @param array   $publicContact   Full contact table record with uid = 0
-        * @param array   $apcontact       Optional full apcontact table record
-        * @param array   $userContact     Optional full contact table record with uid != 0
+        * @param array   $account         entry of "account-user-view"
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function __construct(BaseURL $baseUrl, int $introduction_id, array $publicContact, array $apcontact = [], array $userContact = [])
+       public function __construct(BaseURL $baseUrl, int $introduction_id, array $account)
        {
-               parent::__construct($baseUrl, $publicContact, new Fields(), $apcontact, $userContact);
+               parent::__construct($baseUrl, $account, new Fields());
 
                $this->id = $introduction_id;
        }