diff --git a/lib/Command/NoteBoost.php b/lib/Command/NoteBoost.php index b435c10c..ff9be421 100644 --- a/lib/Command/NoteBoost.php +++ b/lib/Command/NoteBoost.php @@ -134,11 +134,11 @@ class NoteBoost extends Base { $actor = $this->accountService->getActorFromUserId($userId); $this->noteService->setViewer($actor); - - if ($input->getOption('unboost') === null) { + $token = ''; + if (!$input->getOption('unboost')) { $activity = $this->boostService->create($actor, $noteId, $token); } else { - $activity= $this->boostService->delete($actor, $noteId, $token ); + $activity= $this->boostService->delete($actor, $noteId, $token); } echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"; diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php index ae226e1c..30020aea 100644 --- a/lib/Db/NotesRequest.php +++ b/lib/Db/NotesRequest.php @@ -177,14 +177,17 @@ class NotesRequest extends NotesRequestBuilder { $qb = $this->getNotesSelectSql(); $this->limitToObjectId($qb, $objectId); $this->limitToType($qb, $type); - $this->limitToActorId($qb, $actor->getId()); + $this->limitToAttributedTo($qb, $actor->getId()); $cursor = $qb->execute(); $data = $cursor->fetch(); $cursor->closeCursor(); if ($data === false) { - throw new NoteNotFoundException('Post not found'); + throw new NoteNotFoundException( + 'StreamByObjectId not found - ' . $actor->getId() . ' - ' . $type . ' - ' + . $objectId + ); } return $this->parseNotesSelectSql($data); diff --git a/lib/Service/BoostService.php b/lib/Service/BoostService.php index b0e22aaa..829bc3e1 100644 --- a/lib/Service/BoostService.php +++ b/lib/Service/BoostService.php @@ -105,6 +105,7 @@ class BoostService { * @return ACore * @throws NoteNotFoundException * @throws SocialAppConfigException + * @throws Exception */ public function create(Person $actor, string $postId, string &$token = ''): ACore { @@ -123,10 +124,10 @@ class BoostService { } $announce->addCc($note->getAttributedTo()); + $announce->setObjectId($note->getId()); if ($note->isLocal()) { $announce->setObject($note); } else { - $announce->setObjectId($note->getId()); $announce->addCacheItem($note->getId()); } @@ -159,13 +160,13 @@ class BoostService { /** * @param Person $actor * @param string $postId - * @param ACore $undo + * @param string $token * - * @return string - * @throws SocialAppConfigException + * @return ACore * @throws NoteNotFoundException + * @throws SocialAppConfigException */ - public function delete(Person $actor, string $postId, ACore &$undo = null): string { + public function delete(Person $actor, string $postId, string &$token = ''): ACore { $undo = new Undo(); $this->noteService->assignItem($undo, $actor, Stream::TYPE_PUBLIC); $undo->setActor($actor); @@ -176,6 +177,7 @@ class BoostService { } $announce = $this->notesRequest->getNoteByObjectId($actor, Announce::TYPE, $postId); + $undo->setObject($announce); $undo->setCcArray($announce->getCcArray()); @@ -184,9 +186,8 @@ class BoostService { $this->signatureService->signObject($actor, $undo); $token = $this->activityService->request($undo); - return $token; + return $undo; } - }