]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Api/Mastodon/Relationship.php
Correct format/style errors
[friendica.git] / src / Object / Api / Mastodon / Relationship.php
index 870acb54466178407f8fc9747df59de963cd41de..42d0e73119bc315f6efccc7f99adec658ec50127 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -79,7 +79,7 @@ class Relationship extends BaseDataTransferObject
         */
        public function __construct(int $contactId, array $contactRecord = [], bool $blocked = false, bool $muted = false)
        {
-               $this->id                   = $contactId;
+               $this->id                   = (string)$contactId;
                $this->following            = false;
                $this->requested            = false;
                $this->endorsed             = false;
@@ -94,9 +94,9 @@ class Relationship extends BaseDataTransferObject
                $this->note                 = '';
 
                if ($contactRecord['uid'] != 0) {
-                       $this->following   = in_array($contactRecord['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND]);
+                       $this->following   = !$contactRecord['pending'] && in_array($contactRecord['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND]);
                        $this->requested   = (bool)($contactRecord['pending'] ?? false);
-                       $this->followed_by = in_array($contactRecord['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND]);
+                       $this->followed_by = !$contactRecord['pending'] && in_array($contactRecord['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND]);
                        $this->muting      = (bool)($contactRecord['readonly'] ?? false) || $muted;
                        $this->notifying   = (bool)$contactRecord['notify_new_posts'] ?? false;
                        $this->blocking    = (bool)($contactRecord['blocked'] ?? false) || $blocked;