summaryrefslogtreecommitdiffstats
path: root/lib/Command
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/Command
parent36f7b7290bfab599610b779d83b12806fddacfce (diff)
Returns if a post is boosted, and allow unboost
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Command')
-rw-r--r--lib/Command/NoteBoost.php26
-rw-r--r--lib/Command/NoteCreate.php13
2 files changed, 31 insertions, 8 deletions
diff --git a/lib/Command/NoteBoost.php b/lib/Command/NoteBoost.php
index dd1888ff..b435c10c 100644
--- a/lib/Command/NoteBoost.php
+++ b/lib/Command/NoteBoost.php
@@ -30,10 +30,12 @@ declare(strict_types=1);
namespace OCA\Social\Command;
+
use Exception;
use OC\Core\Command\Base;
use OCA\Social\Service\AccountService;
use OCA\Social\Service\ActivityService;
+use OCA\Social\Service\BoostService;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\CurlService;
use OCA\Social\Service\MiscService;
@@ -44,6 +46,11 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+/**
+ * Class NoteBoost
+ *
+ * @package OCA\Social\Command
+ */
class NoteBoost extends Base {
@@ -59,6 +66,9 @@ class NoteBoost extends Base {
/** @var AccountService */
private $accountService;
+ /** @var BoostService */
+ private $boostService;
+
/** @var PostService */
private $postService;
@@ -70,11 +80,12 @@ class NoteBoost extends Base {
/**
- * NoteCreate constructor.
+ * NoteBoost constructor.
*
* @param ActivityService $activityService
* @param AccountService $accountService
* @param NoteService $noteService
+ * @param BoostService $boostService
* @param PostService $postService
* @param CurlService $curlService
* @param ConfigService $configService
@@ -82,13 +93,14 @@ class NoteBoost extends Base {
*/
public function __construct(
ActivityService $activityService, AccountService $accountService,
- NoteService $noteService, PostService $postService, CurlService $curlService,
- ConfigService $configService, MiscService $miscService
+ NoteService $noteService, BoostService $boostService, PostService $postService,
+ CurlService $curlService, ConfigService $configService, MiscService $miscService
) {
parent::__construct();
$this->activityService = $activityService;
$this->noteService = $noteService;
+ $this->boostService = $boostService;
$this->accountService = $accountService;
$this->postService = $postService;
$this->curlService = $curlService;
@@ -105,6 +117,7 @@ class NoteBoost extends Base {
$this->setName('social:note:boost')
->addArgument('userid', InputArgument::REQUIRED, 'userId of the author')
->addArgument('note', InputArgument::REQUIRED, 'Note to boost')
+ ->addOption('unboost', '',InputOption::VALUE_NONE, 'Unboost')
->setDescription('Boost a note');
}
@@ -121,7 +134,12 @@ class NoteBoost extends Base {
$actor = $this->accountService->getActorFromUserId($userId);
$this->noteService->setViewer($actor);
- $token = $this->noteService->createBoost($actor, $noteId, $activity);
+
+ if ($input->getOption('unboost') === null) {
+ $activity = $this->boostService->create($actor, $noteId, $token);
+ } else {
+ $activity= $this->boostService->delete($actor, $noteId, $token );
+ }
echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
echo 'token: ' . $token . "\n";
diff --git a/lib/Command/NoteCreate.php b/lib/Command/NoteCreate.php
index 99c3d18c..b6b8edb5 100644
--- a/lib/Command/NoteCreate.php
+++ b/lib/Command/NoteCreate.php
@@ -30,6 +30,7 @@ declare(strict_types=1);
namespace OCA\Social\Command;
+
use Exception;
use OC\Core\Command\Base;
use OCA\Social\Model\Post;
@@ -45,6 +46,11 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+/**
+ * Class NoteCreate
+ *
+ * @package OCA\Social\Command
+ */
class NoteCreate extends Base {
@@ -78,9 +84,8 @@ class NoteCreate extends Base {
* @param MiscService $miscService
*/
public function __construct(
- ActivityService $activityService, AccountService $accountService,
- PostService $postService, CurlService $curlService,
- ConfigService $configService, MiscService $miscService
+ ActivityService $activityService, AccountService $accountService, PostService $postService,
+ CurlService $curlService, ConfigService $configService, MiscService $miscService
) {
parent::__construct();
@@ -142,7 +147,7 @@ class NoteCreate extends Base {
$post->addTo(($to === null) ? '' : $to);
$post->setHashtags(($hashtag === null) ? [] : [$hashtag]);
- $token = $this->postService->createPost($post, $activity);
+ $activity = $this->postService->createPost($post, $token);
echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
echo 'token: ' . $token . "\n";