<?php
/**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Asika\SimpleConsole\CommandArgsException;
use Asika\SimpleConsole\Console;
use Console_Table;
+use Friendica\Core\Worker;
use Friendica\Moderation\DomainPatternBlocklist;
/**
{
$filename = $this->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
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");
*/
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) {
} 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));
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));