sforkowany z mirror/friendica
StdClass instead of arrays
rodzic
07ccfb212b
commit
1bca280eae
|
@ -31,6 +31,7 @@ use Friendica\Network\HTTPException;
|
|||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Repository\ProfileField;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use stdClass;
|
||||
|
||||
class Status extends BaseFactory
|
||||
{
|
||||
|
@ -62,9 +63,10 @@ class Status extends BaseFactory
|
|||
$item = Item::selectFirst([], ['uri-id' => $uriId, 'uid' => $uid]);
|
||||
$account = DI::mstdnAccount()->createFromContactId($item['author-id']);
|
||||
|
||||
$count['replies'] = DBA::count('item', ['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_COMMENT]);
|
||||
$count['reblogs'] = DBA::count('item', ['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::ANNOUNCE)]);
|
||||
$count['favourites'] = DBA::count('item', ['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::LIKE)]);
|
||||
$count = new stdClass;
|
||||
$count->replies = DBA::count('item', ['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_COMMENT]);
|
||||
$count->reblogs = DBA::count('item', ['thr-parent-id' => $uriId, 'uid' => $uid, 'gravity' => GRAVITY_ACTIVITY, 'vid' => Verb::getID(Activity::ANNOUNCE)]);
|
||||
$count->favourites = 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);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Object\Api\Mastodon;
|
|||
use Friendica\BaseEntity;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class Status
|
||||
|
@ -95,7 +96,7 @@ class Status extends BaseEntity
|
|||
* @param array $item
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function __construct(array $item, Account $account, array $count)
|
||||
public function __construct(array $item, Account $account, stdClass $count)
|
||||
{
|
||||
$this->id = (string)$item['uri-id'];
|
||||
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::ATOM);
|
||||
|
@ -114,9 +115,9 @@ class Status extends BaseEntity
|
|||
$this->language = null;
|
||||
$this->uri = $item['uri'];
|
||||
$this->url = $item['plink'] ?? null;
|
||||
$this->replies_count = $count['replies'];
|
||||
$this->reblogs_count = $count['reblogs'];
|
||||
$this->favourites_count = $count['favourites'];
|
||||
$this->replies_count = $count->replies;
|
||||
$this->reblogs_count = $count->reblogs;
|
||||
$this->favourites_count = $count->favourites;
|
||||
$this->favourited = false;
|
||||
$this->reblogged = false;
|
||||
$this->muted = false;
|
||||
|
|
Ładowanie…
Reference in New Issue