diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-03-13 12:19:19 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-05-03 16:30:39 -0100 |
commit | 9a26da0266828a45bcafcd93c3623d98c3902ce5 (patch) | |
tree | 708832de6b84f724b9fed9e9ef5d00f325d4b60e /lib/Service | |
parent | 3afacf2486536fffdaca69bac13a063a0f41550c (diff) |
fixing local creation
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Service')
-rw-r--r-- | lib/Service/NoteService.php | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Service/NoteService.php b/lib/Service/NoteService.php index d0bf47ac..5788bebc 100644 --- a/lib/Service/NoteService.php +++ b/lib/Service/NoteService.php @@ -66,6 +66,9 @@ class NoteService { /** @var SignatureService */ private $signatureService; + /** @var StreamQueueService */ + private $streamQueueService; + /** @var CacheActorService */ private $cacheActorService; @@ -87,6 +90,7 @@ class NoteService { * @param ActivityService $activityService * @param AccountService $accountService * @param SignatureService $signatureService + * @param StreamQueueService $streamQueueService * @param CacheActorService $cacheActorService * @param ConfigService $configService * @param MiscService $miscService @@ -94,12 +98,14 @@ class NoteService { public function __construct( NotesRequest $notesRequest, ActivityService $activityService, AccountService $accountService, SignatureService $signatureService, - CacheActorService $cacheActorService, ConfigService $configService, MiscService $miscService + StreamQueueService $streamQueueService, CacheActorService $cacheActorService, + ConfigService $configService, MiscService $miscService ) { $this->notesRequest = $notesRequest; $this->activityService = $activityService; $this->accountService = $accountService; $this->signatureService = $signatureService; + $this->streamQueueService = $streamQueueService; $this->cacheActorService = $cacheActorService; $this->configService = $configService; $this->miscService = $miscService; @@ -123,26 +129,32 @@ class NoteService { * @return string * @throws NoteNotFoundException * @throws SocialAppConfigException + * @throws Exception */ public function createBoost(Person $actor, string $postId, ACore &$announce = null): string { $announce = new Announce(); $this->assignStream($announce, $actor, Stream::TYPE_PUBLIC); - $announce->setActor($actor); + $note = $this->getNoteById($postId, true); + if ($note->getType() !== Note::TYPE) { + throw new NoteNotFoundException('Stream is not a Note'); + } $announce->addCc($note->getAttributedTo()); if ($note->isLocal()) { $announce->setObject($note); } else { $announce->setObjectId($note->getId()); + $announce->addCacheItem($note->getId()); } $this->signatureService->signObject($actor, $announce); - $this->notesRequest->save($announce); $token = $this->activityService->request($announce); + $this->streamQueueService->cacheStreamByToken($token); + return $token; } |