3 namespace Friendica\Core\Console;
5 use Friendica\Core\Protocol;
6 use Friendica\Database\DBA;
7 use Friendica\Network\Probe;
10 require_once 'include/text.php';
13 * @brief tool to silence accounts on the global community page
15 * With this tool, you can silence an account on the global community page.
16 * Postings from silenced accounts will not be displayed on the community
17 * page. This silencing does only affect the display on the community page,
18 * accounts following the silenced accounts will still get their postings.
20 * License: AGPLv3 or later, same as Friendica
22 * @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
23 * @author Hypolite Petovan <hypolite@mrpetovan.com>
25 class GlobalCommunitySilence extends \Asika\SimpleConsole\Console
27 protected $helpOptions = ['h', 'help', '?'];
29 protected function getHelp()
32 console globalcommunitysilence - Silence remote profile from global community page
34 bin/console globalcommunitysilence <profile_url> [-h|--help|-?] [-v]
37 With this tool, you can silence an account on the global community page.
38 Postings from silenced accounts will not be displayed on the community page.
39 This silencing does only affect the display on the community page, accounts
40 following the silenced accounts will still get their postings.
43 -h|--help|-? Show help information
44 -v Show more debug information.
49 protected function doExecute()
53 if ($this->getOption('v')) {
54 $this->out('Class: ' . __CLASS__);
55 $this->out('Arguments: ' . var_export($this->args, true));
56 $this->out('Options: ' . var_export($this->options, true));
59 if (count($this->args) == 0) {
60 $this->out($this->getHelp());
64 if (count($this->args) > 1) {
65 throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
68 if ($a->getMode()->isInstall()) {
69 throw new RuntimeException('Database isn\'t ready or populated yet');
73 * 1. make nurl from last parameter
74 * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID
75 * 3. set the flag hidden=1 for the contact entry with the found ID
77 $net = Probe::uri($this->getArgument(0));
78 if (in_array($net['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
79 throw new RuntimeException('This account seems not to exist.');
82 $nurl = normalise_link($net['url']);
83 $contact = DBA::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
84 if (DBA::isResult($contact)) {
85 DBA::update("contact", ["hidden" => true], ["id" => $contact["id"]]);
86 $this->out('NOTICE: The account should be silenced from the global community page');
88 throw new RuntimeException('NOTICE: Could not find any entry for this URL (' . $nurl . ')');