3 * @copyright Copyright (C) 2010-2021, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Console;
25 use Friendica\Database\Database;
26 use Friendica\Model\Contact;
30 * tool to silence accounts on the global community page
32 * With this tool, you can silence an account on the global community page.
33 * Postings from silenced accounts will not be displayed on the community
34 * page. This silencing does only affect the display on the community page,
35 * accounts following the silenced accounts will still get their postings.
37 class GlobalCommunitySilence extends \Asika\SimpleConsole\Console
39 protected $helpOptions = ['h', 'help', '?'];
50 protected function getHelp()
53 console globalcommunitysilence - Silence a profile from the global community page
55 bin/console globalcommunitysilence <profile_url> [-h|--help|-?] [-v]
58 With this tool, you can silence an account on the global community page.
59 Postings from silenced accounts will not be displayed on the community page.
60 This silencing does only affect the display on the community page, accounts
61 following the silenced accounts will still get their postings.
64 -h|--help|-? Show help information
65 -v Show more debug information.
70 public function __construct(App\Mode $appMode, Database $dba, array $argv = null)
72 parent::__construct($argv);
74 $this->appMode = $appMode;
78 protected function doExecute()
80 if ($this->getOption('v')) {
81 $this->out('Class: ' . __CLASS__);
82 $this->out('Arguments: ' . var_export($this->args, true));
83 $this->out('Options: ' . var_export($this->options, true));
86 if (count($this->args) == 0) {
87 $this->out($this->getHelp());
91 if (count($this->args) > 1) {
92 throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
95 if ($this->appMode->isInstall()) {
96 throw new RuntimeException('Database isn\'t ready or populated yet');
99 $contact_id = Contact::getIdForURL($this->getArgument(0));
101 $this->dba->update('contact', ['hidden' => true], ['id' => $contact_id]);
102 $this->out('The account has been successfully silenced from the global community page.');
104 throw new RuntimeException('Could not find any public contact entry for this URL (' . $this->getArgument(0) . ')');