From bba12da167ee376752f531dfad2a6177962d557c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 18 Mar 2018 13:25:47 -0400 Subject: [PATCH] Improve Console\GlobalCommunityBlock - Add description comment block - Fix usage description - Actually use argument --- src/Core/Console/GlobalCommunityBlock.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Core/Console/GlobalCommunityBlock.php b/src/Core/Console/GlobalCommunityBlock.php index 569bd78162..1516a8325c 100644 --- a/src/Core/Console/GlobalCommunityBlock.php +++ b/src/Core/Console/GlobalCommunityBlock.php @@ -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 * @author Hypolite Petovan */ class GlobalCommunityBlock extends \Asika\SimpleConsole\Console @@ -17,13 +23,12 @@ class GlobalCommunityBlock extends \Asika\SimpleConsole\Console protected function getHelp() { $help = << [-h|--help|-?] [-v] Description - bin/console globalcommunityblock - 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; } - }