3 namespace Friendica\Core\Console;
5 use Friendica\Core\L10n;
6 use Friendica\Model\Contact;
9 * @brief tool to block an account from the node
11 * With this tool, you can block an account in such a way, that no postings
12 * or comments this account writes are accepted to the node.
14 * License: AGPLv3 or later, same as Friendica
16 * @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
17 * @author Hypolite Petovan <hypolite@mrpetovan.com>
19 class GlobalCommunityBlock extends \Asika\SimpleConsole\Console
21 protected $helpOptions = ['h', 'help', '?'];
23 protected function getHelp()
26 console globalcommunityblock - Block remote profile from interacting with this node
28 bin/console globalcommunityblock <profile_url> [-h|--help|-?] [-v]
31 Blocks an account in such a way that no postings or comments this account writes are accepted to this node.
34 -h|--help|-? Show help information
35 -v Show more debug information.
40 protected function doExecute()
44 if ($this->getOption('v')) {
45 $this->out('Class: ' . __CLASS__);
46 $this->out('Arguments: ' . var_export($this->args, true));
47 $this->out('Options: ' . var_export($this->options, true));
50 if (count($this->args) == 0) {
51 $this->out($this->getHelp());
55 if (count($this->args) > 1) {
56 throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
59 if ($a->getMode()->isInstall()) {
60 throw new \RuntimeException('Database isn\'t ready or populated yet');
63 $contact_id = Contact::getIdForURL($this->getArgument(0));
65 throw new \RuntimeException(L10n::t('Could not find any contact entry for this URL (%s)', $this->getArgument(0)));
67 if(Contact::block($contact_id)) {
68 $this->out(L10n::t('The contact has been blocked from the node'));
70 throw new \RuntimeException('The contact block failed.');