Improve Console\GlobalCommunityBlock

- Add description comment block
- Fix usage description
- Actually use argument
This commit is contained in:
Hypolite Petovan 2018-03-18 13:25:47 -04:00
parent 881c7ccfc1
commit bba12da167

View File

@ -6,8 +6,14 @@ use Friendica\Core\L10n;
use Friendica\Model\Contact;
/**
* Description of GlobalCommunityBlock
* @brief tool to block an account from the node
*
* With this tool, you can block an account in such a way, that no postings
* or comments this account writes are accepted to the node.
*
* License: AGPLv3 or later, same as Friendica
*
* @author Tobias Diekershoff <mrpetovan@gmail.com>
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class GlobalCommunityBlock extends \Asika\SimpleConsole\Console
@ -17,13 +23,12 @@ class GlobalCommunityBlock extends \Asika\SimpleConsole\Console
protected function getHelp()
{
$help = <<<HELP
console globalcommunityblock - Silence remote profile from global community page
console globalcommunityblock - Block remote profile from interacting with this node
Usage
bin/console globalcommunityblock <profile_url> [-h|--help|-?] [-v]
Description
bin/console globalcommunityblock <profile_url>
Silences the provided remote profile URL from the global community page
Blocks an account in such a way that no postings or comments this account writes are accepted to this node.
Options
-h|--help|-? Show help information
@ -57,14 +62,16 @@ HELP;
throw new \RuntimeException('Unable to connect to database');
}
$contact_id = Contact::getIdForURL($argv[1]);
$contact_id = Contact::getIdForURL($this->getArgument(0));
if (!$contact_id) {
throw new \RuntimeException(L10n::t('Could not find any contact entry for this URL (%s)', $nurl));
}
Contact::block($contact_id);
$this->out(L10n::t('The contact has been blocked from the node'));
if(Contact::block($contact_id)) {
$this->out(L10n::t('The contact has been blocked from the node'));
} else {
throw new \RuntimeException('The contact block failed.');
}
return 0;
}
}