diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-04-10 13:57:12 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-05-03 16:31:15 -0100 |
commit | 47b22680211ba56cf95dee74402fab6394c834fd (patch) | |
tree | 743e8b174c06bfad52dda23bd98edeac522bba8e /lib/Service/BoostService.php | |
parent | 0f714cfda1fae9c8c1d9703fd7cc1a1070b5b1b2 (diff) |
generate token and cache content
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Service/BoostService.php')
-rw-r--r-- | lib/Service/BoostService.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/Service/BoostService.php b/lib/Service/BoostService.php index 7a16bd27..dfd53a0a 100644 --- a/lib/Service/BoostService.php +++ b/lib/Service/BoostService.php @@ -30,7 +30,9 @@ declare(strict_types=1); namespace OCA\Social\Service; +use daita\MySmallPhpTools\Traits\TStringTools; use Exception; +use OCA\Social\AP; use OCA\Social\Db\NotesRequest; use OCA\Social\Exceptions\NoteNotFoundException; use OCA\Social\Exceptions\SocialAppConfigException; @@ -49,6 +51,9 @@ use OCA\Social\Model\ActivityPub\Stream; class BoostService { + use TStringTools; + + /** @var NotesRequest */ private $notesRequest; @@ -125,19 +130,17 @@ class BoostService { $announce->addCc($note->getAttributedTo()); $announce->setObjectId($note->getId()); - if ($note->isLocal()) { - $announce->setObject($note); - } else { - $announce->addCacheItem($note->getId()); - } + $announce->setRequestToken($this->uuid()); - $this->notesRequest->save($announce); + $interface = AP::$activityPub->getInterfaceFromType(Announce::TYPE); + $interface->save($announce); $this->streamActionService->setActionBool($actor->getId(), $postId, 'boosted', true); $this->signatureService->signObject($actor, $announce); + $token = $this->activityService->request($announce); - $this->streamQueueService->cacheStreamByToken($token); + $this->streamQueueService->cacheStreamByToken($announce->getRequestToken()); return $announce; } @@ -184,6 +187,7 @@ class BoostService { $this->notesRequest->deleteNoteById($announce->getId()); $this->streamActionService->setActionBool($actor->getId(), $postId, 'boosted', false); $this->signatureService->signObject($actor, $undo); + $token = $this->activityService->request($undo); return $undo; |