X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FConsole%2FServerBlock.php;h=4d04dcff81e0d23847af76a05fe399728f1ea8b6;hb=e659a0314086dd700dbe5e754e383ab758725805;hp=9ef6777db73d3cf307514922775522c5084ec26c;hpb=1810b32c26683bb94fee10de2ffe18de1a7e85bf;p=friendica.git diff --git a/src/Console/ServerBlock.php b/src/Console/ServerBlock.php index 9ef6777db7..4d04dcff81 100644 --- a/src/Console/ServerBlock.php +++ b/src/Console/ServerBlock.php @@ -1,6 +1,6 @@ getArgument(1); + if (empty($filename)) { + $this->out('A file name is required, e.g. ./bin/console serverblock export backup.csv'); + return 1; + } + $this->blocklist->exportToFile($filename); // Success @@ -127,6 +133,7 @@ HELP; if ($this->blocklist->append($newBlockList)) { $this->out(sprintf("Entries from %s that were not blocked before are now blocked", $filename)); + Worker::add(Worker::PRIORITY_LOW, 'UpdateBlockedServers'); return 0; } else { $this->out("Couldn't save the block list"); @@ -155,12 +162,12 @@ HELP; */ private function addBlockedServer(): int { - if (count($this->args) < 2 || count($this->args) > 3) { - throw new CommandArgsException('Add needs a domain pattern and optionally a reason.'); + if (count($this->args) != 3) { + throw new CommandArgsException('Add needs a domain pattern and a reason.'); } $pattern = $this->getArgument(1); - $reason = (count($this->args) === 3) ? $this->getArgument(2) : DomainPatternBlocklist::DEFAULT_REASON; + $reason = $this->getArgument(2); $result = $this->blocklist->addPattern($pattern, $reason); if ($result) { @@ -169,6 +176,7 @@ HELP; } else { $this->out(sprintf("The domain pattern '%s' is now blocked. (Reason: '%s')", $pattern, $reason)); } + Worker::add(Worker::PRIORITY_LOW, 'UpdateBlockedServers'); return 0; } else { $this->out(sprintf("Couldn't save '%s' as blocked domain pattern", $pattern)); @@ -193,6 +201,7 @@ HELP; if ($result) { if ($result == 2) { $this->out(sprintf("The domain pattern '%s' isn't blocked anymore", $pattern)); + Worker::add(Worker::PRIORITY_LOW, 'UpdateBlockedServers'); return 0; } else { $this->out(sprintf("The domain pattern '%s' wasn't blocked.", $pattern));