summaryrefslogtreecommitdiffstats
path: root/lib/Controller/LocalController.php
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-04-08 15:52:03 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-05-03 16:31:15 -0100
commitb4d773940c9d6c601a2dc9a2ba39c0f6348e9545 (patch)
tree4b0ae964c51e8e8c8fc2f5411a180c177bc71858 /lib/Controller/LocalController.php
parent36f7b7290bfab599610b779d83b12806fddacfce (diff)
Returns if a post is boosted, and allow unboost
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Controller/LocalController.php')
-rw-r--r--lib/Controller/LocalController.php38
1 files changed, 35 insertions, 3 deletions
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php
index bd1978a6..d28cd49b 100644
--- a/lib/Controller/LocalController.php
+++ b/lib/Controller/LocalController.php
@@ -41,6 +41,7 @@ use OCA\Social\Model\ActivityPub\Actor\Person;
use OCA\Social\Model\ActivityPub\Stream;
use OCA\Social\Model\Post;
use OCA\Social\Service\AccountService;
+use OCA\Social\Service\BoostService;
use OCA\Social\Service\CacheActorService;
use OCA\Social\Service\DocumentService;
use OCA\Social\Service\FollowService;
@@ -77,6 +78,9 @@ class LocalController extends Controller {
/** @var FollowService */
private $followService;
+ /** @var BoostService */
+ private $boostService;
+
/** @var PostService */
private $postService;
@@ -111,6 +115,7 @@ class LocalController extends Controller {
* @param PostService $postService
* @param NoteService $noteService
* @param SearchService $searchService
+ * @param BoostService $boostService
* @param DocumentService $documentService
* @param MiscService $miscService
*/
@@ -118,7 +123,7 @@ class LocalController extends Controller {
IRequest $request, $userId, AccountService $accountService,
CacheActorService $cacheActorService, FollowService $followService,
PostService $postService, NoteService $noteService, SearchService $searchService,
- DocumentService $documentService, MiscService $miscService
+ BoostService $boostService, DocumentService $documentService, MiscService $miscService
) {
parent::__construct(Application::APP_NAME, $request);
@@ -129,6 +134,7 @@ class LocalController extends Controller {
$this->searchService = $searchService;
$this->postService = $postService;
$this->followService = $followService;
+ $this->boostService = $boostService;
$this->documentService = $documentService;
$this->miscService = $miscService;
}
@@ -156,7 +162,7 @@ class LocalController extends Controller {
$post->setHashtags($this->getArray('hashtags', $data, []));
/** @var ACore $activity */
- $token = $this->postService->createPost($post, $activity);
+ $activity = $this->postService->createPost($post, $token);
return $this->success(
[
@@ -208,8 +214,34 @@ class LocalController extends Controller {
public function postBoost(string $postId): DataResponse {
try {
$this->initViewer(true);
+ $announce = $this->boostService->create($this->viewer, $postId, $token);
+
+ return $this->success(
+ [
+ 'boost' => $announce,
+ 'token' => $token
+ ]
+ );
+ } catch (Exception $e) {
+ return $this->fail($e);
+ }
+ }
+
+
+ /**
+ * Delete a boost.
+ *
+ * @NoAdminRequired
+ *
+ * @param string $postId
+ *
+ * @return DataResponse
+ */
+ public function postUnboost(string $postId): DataResponse {
+ try {
+ $this->initViewer(true);
- $token = $this->noteService->createBoost($this->viewer, $postId, $announce);
+ $token = $this->boostService->delete($this->viewer, $postId, $announce);
return $this->success(
[