From 4a6c8f12af0dbb76bc0bc3f91158ffaecd453ead Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Wed, 16 Jan 2019 12:06:20 -0100 Subject: cache Actor on followed/unfollowed + following/unfollowing Signed-off-by: Maxence Lange --- lib/Service/PostService.php | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'lib/Service/PostService.php') diff --git a/lib/Service/PostService.php b/lib/Service/PostService.php index b2f39ac8..a1e08e3f 100644 --- a/lib/Service/PostService.php +++ b/lib/Service/PostService.php @@ -30,9 +30,17 @@ declare(strict_types=1); namespace OCA\Social\Service; -use Exception; -use OC\User\NoUserException; -use OCA\Social\Exceptions\ActorDoesNotExistException; +use daita\MySmallPhpTools\Exceptions\MalformedArrayException; +use OCA\Social\Exceptions\InvalidOriginException; +use OCA\Social\Exceptions\InvalidResourceException; +use OCA\Social\Exceptions\ItemUnknownException; +use OCA\Social\Exceptions\NoteNotFoundException; +use OCA\Social\Exceptions\RedundancyLimitException; +use OCA\Social\Exceptions\RequestContentException; +use OCA\Social\Exceptions\RequestNetworkException; +use OCA\Social\Exceptions\RequestResultNotJsonException; +use OCA\Social\Exceptions\RequestResultSizeException; +use OCA\Social\Exceptions\RequestServerException; use OCA\Social\Exceptions\SocialAppConfigException; use OCA\Social\Model\ActivityPub\ACore; use OCA\Social\Model\Post; @@ -77,23 +85,29 @@ class PostService { * @param ACore $activity * * @return string - * @throws ActorDoesNotExistException - * @throws NoUserException * @throws SocialAppConfigException - * @throws Exception + * @throws InvalidOriginException + * @throws InvalidResourceException + * @throws ItemUnknownException + * @throws NoteNotFoundException + * @throws RedundancyLimitException + * @throws RequestContentException + * @throws RequestNetworkException + * @throws RequestResultNotJsonException + * @throws RequestResultSizeException + * @throws RequestServerException + * @throws MalformedArrayException */ public function createPost(Post $post, ACore &$activity = null): string { $note = $this->noteService->generateNote( - $post->getUserId(), htmlentities($post->getContent(), ENT_QUOTES), $post->getType() + $post->getActor(), htmlentities($post->getContent(), ENT_QUOTES), $post->getType() ); - + $this->noteService->replyTo($note, $post->getReplyTo()); $this->noteService->addRecipients($note, $post->getType(), $post->getTo()); - $actor = $this->actorService->getActorFromUserId($post->getUserId()); - - return $this->activityService->createActivity($actor, $note, $activity); + return $this->activityService->createActivity($post->getActor(), $note, $activity); } -- cgit v1.2.3