X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FConsole%2FRelay.php;h=f417b51924fa8330ce9c040641a16d869161529b;hb=122ad0af14f046c2462a03fe33967dc41abfc8b5;hp=5d7c8b3f70e13a67afe3298296f02c4dc501cf3d;hpb=c6b45a958e3b09bc8f3950a718c181dfc9e0b910;p=friendica.git diff --git a/src/Console/Relay.php b/src/Console/Relay.php index 5d7c8b3f70..f417b51924 100644 --- a/src/Console/Relay.php +++ b/src/Console/Relay.php @@ -47,12 +47,12 @@ class Relay extends \Asika\SimpleConsole\Console $help = << [-h|--help|-?] [-v] - bin/console relay remove [-h|--help|-?] [-v] + bin/console relay remove [-f|--force] [-h|--help|-?] [-v] Description - bin/console relay + bin/console relay list Lists all active relay servers bin/console relay add @@ -62,6 +62,7 @@ Description Remove a relay actor in the format https://relayserver.tld/actor Options + -f|--force Change the relay status in the system even if the unsubscribe message failed -h|--help|-? Show help information -v Show more debug information. HELP; @@ -88,18 +89,18 @@ HELP; throw new CommandArgsException('Too many arguments'); } - if (count($this->args) == 1) { - throw new CommandArgsException('Too few arguments'); - } - - if (count($this->args) == 0) { + if ((count($this->args) == 1) && ($this->getArgument(0) == 'list')) { $contacts = $this->dba->select('apcontact', ['url'], - ["`type` = ? AND `url` IN (SELECT `url` FROM `contact` WHERE `uid` = ? AND `rel` IN (?, ?))", - 'Application', 0, Contact::FOLLOWER, Contact::FRIEND]); + ["`type` = ? AND `url` IN (SELECT `url` FROM `contact` WHERE `uid` = ? AND `rel` = ?)", + 'Application', 0, Contact::FRIEND]); while ($contact = $this->dba->fetch($contacts)) { $this->out($contact['url']); } $this->dba->close($contacts); + } elseif (count($this->args) == 0) { + throw new CommandArgsException('too few arguments'); + } elseif (count($this->args) == 1) { + throw new CommandArgsException($this->getArgument(0) . ' is no valid command'); } if (count($this->args) == 2) { @@ -119,10 +120,14 @@ HELP; $this->out($actor . " couldn't be added"); } } elseif ($mode == 'remove') { - if (Transmitter::sendRelayUndoFollow($actor)) { + $force = $this->getOption(['f', 'force'], false); + + if (Transmitter::sendRelayUndoFollow($actor, $force)) { $this->out('Successfully removed ' . $actor); - } else { + } elseif (!$force) { $this->out($actor . " couldn't be removed"); + } else { + $this->out($actor . " is forcefully removed"); } } else { throw new CommandArgsException($mode . ' is no valid command');