From bcb91ac143ee8517eff07f2351c9cc63f1643d25 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Tue, 21 Mar 2023 10:25:11 -0100 Subject: [PATCH] fix unreblog Signed-off-by: Maxence Lange --- lib/Model/ActivityPub/Stream.php | 2 +- lib/Service/ActionService.php | 7 +++++-- lib/Service/BoostService.php | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/Model/ActivityPub/Stream.php b/lib/Model/ActivityPub/Stream.php index 312ad91b..274ae0b9 100644 --- a/lib/Model/ActivityPub/Stream.php +++ b/lib/Model/ActivityPub/Stream.php @@ -630,7 +630,7 @@ class Stream extends ACore implements IQueryRow, JsonSerializable { "content" => $this->getContent(), "sensitive" => $this->isSensitive(), "spoiler_text" => $this->getSpoilerText(), - 'visibility' => ($this->getVisibility() === '') ? 'unknown' : $this->getVisibility(), + 'visibility' => $this->getVisibility(), "language" => $this->getLanguage(), "in_reply_to_id" => null, "in_reply_to_account_id" => null, diff --git a/lib/Service/ActionService.php b/lib/Service/ActionService.php index 704c59d4..b318c795 100644 --- a/lib/Service/ActionService.php +++ b/lib/Service/ActionService.php @@ -139,7 +139,10 @@ class ActionService { } private function reblog(Person $actor, string $postId, bool $enabled = true): void { - $this->boostService->create($actor, $postId); - //$this->streamActionService->setActionBool($actor->getId(), $postId, StreamAction::BOOSTED, $enabled); + if ($enabled) { + $this->boostService->create($actor, $postId); + } else { + $this->boostService->delete($actor, $postId); + } } } diff --git a/lib/Service/BoostService.php b/lib/Service/BoostService.php index f34d68e7..668d5393 100644 --- a/lib/Service/BoostService.php +++ b/lib/Service/BoostService.php @@ -105,7 +105,7 @@ class BoostService { * @throws SocialAppConfigException * @throws Exception */ - public function create(Person $actor, string $postId, &$token = ''): ACore { + public function create(Person $actor, string $postId, string &$token = ''): ACore { /** @var Announce $announce */ $announce = AP::$activityPub->getItemFromType(Announce::TYPE); $this->streamService->assignItem($announce, $actor, Stream::TYPE_ANNOUNCE); @@ -169,7 +169,7 @@ class BoostService { * @throws SocialAppConfigException * @throws StreamNotFoundException */ - public function delete(Person $actor, string $postId, &$token = ''): ACore { + public function delete(Person $actor, string $postId, string &$token = ''): ACore { $undo = new Undo(); $this->streamService->assignItem($undo, $actor, Stream::TYPE_PUBLIC); $undo->setActor($actor); @@ -188,7 +188,7 @@ class BoostService { $interface = AP::$activityPub->getInterfaceFromType(Announce::TYPE); $interface->delete($announce); -// $this->streamRequest->deleteStreamById($announce->getId(), Announce::TYPE); + $this->streamRequest->deleteById($announce->getId(), Announce::TYPE); $this->signatureService->signObject($actor, $undo); $token = $this->activityService->request($undo);