diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-01-16 12:06:20 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-01-16 12:06:20 -0100 |
commit | 4a6c8f12af0dbb76bc0bc3f91158ffaecd453ead (patch) | |
tree | b53717b86264c0705886c6e30914ed1f16171dee /lib/Service/PostService.php | |
parent | 3a1ccc4c87450e02c968dde81a7932f5fce2d1ce (diff) |
cache Actor on followed/unfollowed + following/unfollowing
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Service/PostService.php')
-rw-r--r-- | lib/Service/PostService.php | 36 |
1 files changed, 25 insertions, 11 deletions
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); } |