3 namespace Friendica\Console;
6 use Friendica\Database\Database;
7 use Friendica\Model\Contact;
11 * @brief tool to silence accounts on the global community page
13 * With this tool, you can silence an account on the global community page.
14 * Postings from silenced accounts will not be displayed on the community
15 * page. This silencing does only affect the display on the community page,
16 * accounts following the silenced accounts will still get their postings.
18 * License: AGPLv3 or later, same as Friendica
20 * @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
21 * @author Hypolite Petovan <hypolite@mrpetovan.com>
23 class GlobalCommunitySilence extends \Asika\SimpleConsole\Console
25 protected $helpOptions = ['h', 'help', '?'];
36 protected function getHelp()
39 console globalcommunitysilence - Silence remote profile from global community page
41 bin/console globalcommunitysilence <profile_url> [-h|--help|-?] [-v]
44 With this tool, you can silence an account on the global community page.
45 Postings from silenced accounts will not be displayed on the community page.
46 This silencing does only affect the display on the community page, accounts
47 following the silenced accounts will still get their postings.
50 -h|--help|-? Show help information
51 -v Show more debug information.
56 public function __construct(App\Mode $appMode, Database $dba, array $argv = null)
58 parent::__construct($argv);
60 $this->appMode = $appMode;
64 protected function doExecute()
66 if ($this->getOption('v')) {
67 $this->out('Class: ' . __CLASS__);
68 $this->out('Arguments: ' . var_export($this->args, true));
69 $this->out('Options: ' . var_export($this->options, true));
72 if (count($this->args) == 0) {
73 $this->out($this->getHelp());
77 if (count($this->args) > 1) {
78 throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
81 if ($this->appMode->isInstall()) {
82 throw new RuntimeException('Database isn\'t ready or populated yet');
85 $contact_id = Contact::getIdForURL($this->getArgument(0));
87 $this->dba->update('contact', ['hidden' => true], ['id' => $contact_id]);
88 $this->out('The account has been successfully silenced from the global community page.');
90 throw new RuntimeException('Could not find any public contact entry for this URL (' . $this->getArgument(0) . ')');