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;
$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)
);
* @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;