. * */ 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; use ImagickException; use Psr\Log\LoggerInterface; class FollowRequest extends BaseFactory { /** @var BaseURL */ private $baseUrl; public function __construct(LoggerInterface $logger, BaseURL $baseURL) { parent::__construct($logger); $this->baseUrl = $baseURL; } /** * @param Introduction $introduction * @return \Friendica\Object\Api\Mastodon\FollowRequest * @throws ImagickException|HTTPException\InternalServerErrorException */ public function createFromIntroduction(Introduction $introduction): \Friendica\Object\Api\Mastodon\FollowRequest { $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'); } return new \Friendica\Object\Api\Mastodon\FollowRequest($this->baseUrl, $introduction->id, $account); } }