. * */ namespace Friendica\Factory\Api\Mastodon; use Friendica\App\BaseURL; use Friendica\BaseFactory; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; use Friendica\Model\Verb; use Friendica\Network\HTTPException; use Friendica\Protocol\Activity; use Friendica\Repository\ProfileField; use Psr\Log\LoggerInterface; class Status extends BaseFactory { /** @var BaseURL */ protected $baseUrl; /** @var ProfileField */ protected $profileField; /** @var Field */ protected $mstdnField; public function __construct(LoggerInterface $logger, BaseURL $baseURL, ProfileField $profileField, Field $mstdnField) { parent::__construct($logger); $this->baseUrl = $baseURL; $this->profileField = $profileField; $this->mstdnField = $mstdnField; } /** * @param int $uriId Uri-ID of the item * @param int $uid Item user * @return \Friendica\Object\Api\Mastodon\Status * @throws HTTPException\InternalServerErrorException * @throws \ImagickException */ public function createFromUriId(int $uriId, $uid = 0) { $item = Item::selectFirst([], ['uri-id' => $uriId, 'uid' => $uid]); $account = DI::mstdnAccount()->createFromContactId($item['author-id']); $count = new \Friendica\Object\Api\Mastodon\Status\StatusCounts( DBA::count('item', ['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_COMMENT]), DBA::count('item', ['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::ANNOUNCE)]), DBA::count('item', ['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::LIKE)])); return new \Friendica\Object\Api\Mastodon\Status($item, $account, $count); } }