]> git.mxchange.org Git - friendica.git/blob - src/Module/Api/Mastodon/Instance/Peers.php
Removed unneeded function
[friendica.git] / src / Module / Api / Mastodon / Instance / Peers.php
1 <?php
2
3 namespace Friendica\Module\Api\Mastodon\Instance;
4
5 use Friendica\Core\Protocol;
6 use Friendica\Core\System;
7 use Friendica\Database\DBA;
8 use Friendica\Module\Base\Api;
9 use Friendica\Network\HTTPException;
10 use Friendica\Util\Network;
11
12 /**
13  * Undocumented API endpoint that is implemented by both Mastodon and Pleroma
14  */
15 class Peers extends Api
16 {
17         /**
18          * @param array $parameters
19          * @throws HTTPException\InternalServerErrorException
20          */
21         public static function rawContent(array $parameters = [])
22         {
23                 $return = [];
24
25                 // We only select for Friendica and ActivityPub servers, since it is expected to only deliver AP compatible systems here.
26                 $instances = DBA::select('gserver', ['url'], ["`network` in (?, ?) AND `last_contact` >= `last_failure`", Protocol::DFRN, Protocol::ACTIVITYPUB]);
27                 while ($instance = DBA::fetch($instances)) {
28                         $urldata = parse_url($instance['url']);
29                         unset($urldata['scheme']);
30                         $return[] = ltrim(Network::unparseURL($urldata), '/');
31                 }
32                 DBA::close($instances);
33
34                 System::jsonExit($return);
35         }
36 }