<?php
/**
- * @copyright Copyright (C) 2010-2021, 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 Friendica\Model\APContact;
-use Friendica\Model\Contact;
use Friendica\Protocol\ActivityPub\Transmitter;
+use Friendica\Protocol\Relay as ProtocolRelay;
/**
* tool to control the list of ActivityPub relay servers from the CLI
$this->dba = $dba;
}
- protected function doExecute()
+ protected function doExecute(): int
{
if ($this->getOption('v')) {
$this->out('Executable: ' . $this->executable);
}
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` = ?)",
- 'Application', 0, Contact::FRIEND]);
- while ($contact = $this->dba->fetch($contacts)) {
+ foreach (ProtocolRelay::getList(['url']) as $contact) {
$this->out($contact['url']);
}
- $this->dba->close($contacts);
} elseif (count($this->args) == 0) {
throw new CommandArgsException('too few arguments');
} elseif (count($this->args) == 1) {
$actor = $this->getArgument(1);
$apcontact = APContact::getByURL($actor);
- if (empty($apcontact) || ($apcontact['type'] != 'Application')) {
+ if (empty($apcontact) || !in_array($apcontact['type'], ['Application', 'Service'])) {
$this->out($actor . ' is no relay actor');
return 1;
}