Add dislike counts to Mastodon API Statuses in FriendicaExtension
This commit is contained in:
parent
5f56918d3e
commit
3a8929be1f
4 changed files with 26 additions and 9 deletions
|
@ -144,10 +144,18 @@ class Status extends BaseFactory
|
||||||
'deleted' => false
|
'deleted' => false
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$count_dislike = Post::countPosts([
|
||||||
|
'thr-parent-id' => $uriId,
|
||||||
|
'gravity' => Item::GRAVITY_ACTIVITY,
|
||||||
|
'vid' => Verb::getID(Activity::DISLIKE),
|
||||||
|
'deleted' => false
|
||||||
|
]);
|
||||||
|
|
||||||
$counts = new \Friendica\Object\Api\Mastodon\Status\Counts(
|
$counts = new \Friendica\Object\Api\Mastodon\Status\Counts(
|
||||||
Post::countPosts(['thr-parent-id' => $uriId, 'gravity' => Item::GRAVITY_COMMENT, 'deleted' => false], []),
|
Post::countPosts(['thr-parent-id' => $uriId, 'gravity' => Item::GRAVITY_COMMENT, 'deleted' => false], []),
|
||||||
$count_announce,
|
$count_announce,
|
||||||
$count_like
|
$count_like,
|
||||||
|
$count_dislike
|
||||||
);
|
);
|
||||||
|
|
||||||
$origin_like = ($count_like == 0) ? false : Post::exists([
|
$origin_like = ($count_like == 0) ? false : Post::exists([
|
||||||
|
@ -323,7 +331,7 @@ class Status extends BaseFactory
|
||||||
|
|
||||||
$replies = $this->dba->count('mail', ['thr-parent-id' => $item['uri-id'], 'reply' => true]);
|
$replies = $this->dba->count('mail', ['thr-parent-id' => $item['uri-id'], 'reply' => true]);
|
||||||
|
|
||||||
$counts = new \Friendica\Object\Api\Mastodon\Status\Counts($replies, 0, 0);
|
$counts = new \Friendica\Object\Api\Mastodon\Status\Counts($replies, 0, 0, 0);
|
||||||
|
|
||||||
$userAttributes = new \Friendica\Object\Api\Mastodon\Status\UserAttributes(false, false, false, false, false);
|
$userAttributes = new \Friendica\Object\Api\Mastodon\Status\UserAttributes(false, false, false, false, false);
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ class Status extends BaseDataTransferObject
|
||||||
$this->emojis = [];
|
$this->emojis = [];
|
||||||
$this->card = $card->toArray() ?: null;
|
$this->card = $card->toArray() ?: null;
|
||||||
$this->poll = $poll;
|
$this->poll = $poll;
|
||||||
$this->friendica = new FriendicaExtension($item['title']);
|
$this->friendica = new FriendicaExtension($item['title'], $counts->dislikes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,6 +35,9 @@ class Counts
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $favourites;
|
protected $favourites;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $dislikes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a status count object
|
* Creates a status count object
|
||||||
*
|
*
|
||||||
|
@ -43,14 +46,16 @@ class Counts
|
||||||
* @param int $favourites
|
* @param int $favourites
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function __construct(int $replies, int $reblogs, int $favourites)
|
public function __construct(int $replies, int $reblogs, int $favourites, int $dislikes)
|
||||||
{
|
{
|
||||||
$this->replies = $replies;
|
$this->replies = $replies;
|
||||||
$this->reblogs = $reblogs;
|
$this->reblogs = $reblogs;
|
||||||
$this->favourites = $favourites;
|
$this->favourites = $favourites;
|
||||||
|
$this->dislikes = $dislikes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __get($name) {
|
public function __get($name)
|
||||||
|
{
|
||||||
return $this->$name;
|
return $this->$name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,18 @@ class FriendicaExtension extends BaseDataTransferObject
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $title;
|
protected $title;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $dislikes_count;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a status count object
|
* Creates a status count object
|
||||||
*
|
*
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function __construct(string $title)
|
public function __construct(string $title, int $dislikes_count)
|
||||||
{
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
|
$this->dislikes_count = $dislikes_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue