Apply suggestions from code review

Co-authored-by: Hypolite Petovan <hypolite@mrpetovan.com>
This commit is contained in:
Michael Vogel 2020-09-08 03:39:51 +02:00 committed by GitHub
parent 59374eb6c6
commit 2bb725fa30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 9 deletions

View file

@ -62,11 +62,12 @@ class Status extends BaseFactory
$item = Item::selectFirst([], ['uri-id' => $uriId, 'uid' => $uid]);
$account = DI::mstdnAccount()->createFromContactId($item['author-id']);
$count = new \Friendica\Object\Api\Mastodon\Status\StatusCounts(
$counts = new \Friendica\Object\Api\Mastodon\Status\Counts(
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)]));
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);
return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts);
}
}

View file

@ -23,7 +23,7 @@ namespace Friendica\Object\Api\Mastodon;
use Friendica\BaseEntity;
use Friendica\Content\Text\BBCode;
use Friendica\Object\Api\Mastodon\Status\StatusCounts;
use Friendica\Object\Api\Mastodon\Status\Counts;
use Friendica\Util\DateTimeFormat;
/**
@ -96,7 +96,7 @@ class Status extends BaseEntity
* @param array $item
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(array $item, Account $account, StatusCounts $count)
public function __construct(array $item, Account $account, Counts $counts)
{
$this->id = (string)$item['uri-id'];
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::ATOM);
@ -115,9 +115,9 @@ class Status extends BaseEntity
$this->language = null;
$this->uri = $item['uri'];
$this->url = $item['plink'] ?? null;
$this->replies_count = $count->__get('replies');
$this->reblogs_count = $count->__get('reblogs');
$this->favourites_count = $count->__get('favourites');
$this->replies_count = $counts->replies;
$this->reblogs_count = $counts->reblogs;
$this->favourites_count = $counts->favourites;
$this->favourited = false;
$this->reblogged = false;
$this->muted = false;

View file

@ -26,7 +26,7 @@ namespace Friendica\Object\Api\Mastodon\Status;
*
* @see https://docs.joinmastodon.org/entities/status
*/
class StatusCounts
class Counts
{
/** @var int */
protected $replies;