]> git.mxchange.org Git - friendica.git/blob - src/Object/Api/Mastodon/Relationship.php
Merge pull request #8191 from MrPetovan/task/7967-mastodon-api-custom_emojis
[friendica.git] / src / Object / Api / Mastodon / Relationship.php
1 <?php
2
3 namespace Friendica\Object\Api\Mastodon;
4
5 use Friendica\BaseEntity;
6 use Friendica\Model\Contact;
7 use Friendica\Util\Network;
8
9 /**
10  * Class Relationship
11  *
12  * @see https://docs.joinmastodon.org/api/entities/#relationship
13  */
14 class Relationship extends BaseEntity
15 {
16         /** @var int */
17         protected $id;
18         /** @var bool */
19         protected $following = false;
20         /** @var bool */
21         protected $followed_by = false;
22         /** @var bool */
23         protected $blocking = false;
24         /** @var bool */
25         protected $muting = false;
26         /** @var bool */
27         protected $muting_notifications = false;
28         /** @var bool */
29         protected $requested = false;
30         /** @var bool */
31         protected $domain_blocking = false;
32         /**
33          * Unsupported
34          * @var bool
35          */
36         protected $showing_reblogs = true;
37         /**
38          * Unsupported
39          * @var bool
40          */
41         protected $endorsed = false;
42
43         /**
44          * @param int   $userContactId Contact row Id with uid != 0
45          * @param array $userContact   Full Contact table record with uid != 0
46          */
47         public function __construct(int $userContactId, array $userContact = [])
48         {
49                 $this->id                   = $userContactId;
50                 $this->following            = in_array($userContact['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND]);
51                 $this->followed_by          = in_array($userContact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND]);
52                 $this->blocking             = (bool)$userContact['blocked'] ?? false;
53                 $this->muting               = (bool)$userContact['readonly'] ?? false;
54                 $this->muting_notifications = (bool)$userContact['readonly'] ?? false;
55                 $this->requested            = (bool)$userContact['pending'] ?? false;
56                 $this->domain_blocking      = Network::isUrlBlocked($userContact['url'] ?? '');
57
58                 return $this;
59         }
60 }