summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-10-15 19:09:53 +0200
committerRobin Appelman <robin@icewind.nl>2020-10-19 18:25:06 +0200
commitdd9ed2f972b259ef39df0130cd58b58d94c530d3 (patch)
treedde61e1ea5a82d3e622eee8e5dab1187d7820273 /lib
parentcd86386bffe0911fa8879735a3b18540c50ed71c (diff)
set reblogged and favorited in mastadon api
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/Model/ActivityPub/Stream.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/Model/ActivityPub/Stream.php b/lib/Model/ActivityPub/Stream.php
index a731f2f6..c01660c7 100644
--- a/lib/Model/ActivityPub/Stream.php
+++ b/lib/Model/ActivityPub/Stream.php
@@ -480,6 +480,21 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
* @return array
*/
public function exportAsLocal(): array {
+ $actions = ($this->hasAction()) ? $this->getAction()->getValues() : [];
+ $favorited = false;
+ $reblogged = false;
+ foreach ($actions as $action => $value) {
+ if ($value) {
+ switch ($action) {
+ case StreamAction::BOOSTED:
+ $reblogged = true;
+ break;
+ case StreamAction::LIKED:
+ $favorited = true;
+ break;
+ }
+ }
+ }
$result = [
"content" => $this->getContent(),
"sensitive" => $this->isSensitive(),
@@ -491,8 +506,8 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
'replies_count' => 0,
'reblogs_count' => 0,
'favourites_count' => 0,
- 'favourited' => false,
- 'reblogged' => false,
+ 'favourited' => $favorited,
+ 'reblogged' => $reblogged,
'muted' => false,
'bookmarked' => false,
'uri' => $this->getId(),