streamService = $streamService; $this->likeService = $likeService; $this->accountService = $accountService; $this->miscService = $miscService; } /** * */ protected function configure() { parent::configure(); $this->setName('social:note:like') ->addArgument('user_id', InputArgument::REQUIRED, 'userId of the author') ->addArgument('note_id', InputArgument::REQUIRED, 'Note to like') ->addOption('unlike', '', InputOption::VALUE_NONE, 'Unlike') ->setDescription('Like a note'); } /** * @param InputInterface $input * @param OutputInterface $output * * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { $userId = $input->getArgument('user_id'); $noteId = $input->getArgument('note_id'); $actor = $this->accountService->getActorFromUserId($userId); $this->streamService->setViewer($actor); $token = ''; if (!$input->getOption('unlike')) { $activity = $this->likeService->create($actor, $noteId, $token); } else { $activity = $this->likeService->delete($actor, $noteId, $token); } echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"; echo 'token: ' . $token . "\n"; return 0; } }