diff --git a/src/Factory/Api/Mastodon/Relationship.php b/src/Factory/Api/Mastodon/Relationship.php index f1ca4a1f9e..8ae72ae9b2 100644 --- a/src/Factory/Api/Mastodon/Relationship.php +++ b/src/Factory/Api/Mastodon/Relationship.php @@ -22,6 +22,7 @@ namespace Friendica\Factory\Api\Mastodon; use Exception; +use Friendica\Network\HTTPException; use Friendica\Object\Api\Mastodon\Relationship as RelationshipEntity; use Friendica\BaseFactory; use Friendica\Model\Contact; @@ -41,9 +42,15 @@ class Relationship extends BaseFactory $pcid = !empty($cdata['public']) ? $cdata['public'] : $contactId; $cid = !empty($cdata['user']) ? $cdata['user'] : $contactId; + $contact = Contact::getById($cid); + if (!$contact) { + $this->logger->warning('Target contact not found', ['contactId' => $contactId, 'uid' => $uid, 'pcid' => $pcid, 'cid' => $cid]); + throw new HTTPException\NotFoundException('Contact not found.'); + } + return new RelationshipEntity( $pcid, - Contact::getById($cid), + $contact, Contact\User::isBlocked($cid, $uid), Contact\User::isIgnored($cid, $uid) ); diff --git a/src/Object/Api/Mastodon/Relationship.php b/src/Object/Api/Mastodon/Relationship.php index 42d0e73119..c042e81b5e 100644 --- a/src/Object/Api/Mastodon/Relationship.php +++ b/src/Object/Api/Mastodon/Relationship.php @@ -77,7 +77,7 @@ class Relationship extends BaseDataTransferObject * @param bool $blocked "true" if user is blocked * @param bool $muted "true" if user is muted */ - public function __construct(int $contactId, array $contactRecord = [], bool $blocked = false, bool $muted = false) + public function __construct(int $contactId, array $contactRecord, bool $blocked = false, bool $muted = false) { $this->id = (string)$contactId; $this->following = false;