2019-12-10 21:27:09 +00:00
|
|
|
<?php
|
2020-02-09 14:45:36 +00:00
|
|
|
/**
|
2021-03-29 06:40:20 +00:00
|
|
|
* @copyright Copyright (C) 2010-2021, the Friendica project
|
2020-02-09 14:45:36 +00:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2019-12-10 21:27:09 +00:00
|
|
|
|
|
|
|
namespace Friendica\Module\Api\Mastodon\Instance;
|
|
|
|
|
|
|
|
use Friendica\Core\Protocol;
|
|
|
|
use Friendica\Core\System;
|
|
|
|
use Friendica\Database\DBA;
|
2020-01-28 02:18:42 +00:00
|
|
|
use Friendica\Module\BaseApi;
|
2019-12-10 21:27:09 +00:00
|
|
|
use Friendica\Network\HTTPException;
|
|
|
|
use Friendica\Util\Network;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Undocumented API endpoint that is implemented by both Mastodon and Pleroma
|
|
|
|
*/
|
2020-01-28 02:18:42 +00:00
|
|
|
class Peers extends BaseApi
|
2019-12-10 21:27:09 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @throws HTTPException\InternalServerErrorException
|
|
|
|
*/
|
2021-11-14 19:46:25 +00:00
|
|
|
public static function rawContent()
|
2019-12-10 21:27:09 +00:00
|
|
|
{
|
|
|
|
$return = [];
|
|
|
|
|
|
|
|
// We only select for Friendica and ActivityPub servers, since it is expected to only deliver AP compatible systems here.
|
2020-07-19 11:42:23 +00:00
|
|
|
$instances = DBA::select('gserver', ['url'], ["`network` in (?, ?) AND NOT `failed`", Protocol::DFRN, Protocol::ACTIVITYPUB]);
|
2019-12-10 21:27:09 +00:00
|
|
|
while ($instance = DBA::fetch($instances)) {
|
|
|
|
$urldata = parse_url($instance['url']);
|
|
|
|
unset($urldata['scheme']);
|
|
|
|
$return[] = ltrim(Network::unparseURL($urldata), '/');
|
|
|
|
}
|
|
|
|
DBA::close($instances);
|
|
|
|
|
|
|
|
System::jsonExit($return);
|
|
|
|
}
|
|
|
|
}
|