]> git.mxchange.org Git - friendica.git/commitdiff
Retrieve data about Mastodon servers
authorMichael <heluecht@pirati.ca>
Wed, 6 Dec 2017 20:09:59 +0000 (20:09 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 6 Dec 2017 20:09:59 +0000 (20:09 +0000)
doc/htconfig.md
src/Protocol/PortableContact.php

index 3f5b28b91727443dd748a82b6f70c6f7f6e84791..10536141c59a7f841ff78d1cf5b4950e6245a1ba 100644 (file)
@@ -46,6 +46,7 @@ Example: To set the directory value please add this line to your .htconfig.php:
 * **frontend_worker_timeout** - Value in minutes after we think that a frontend task was killed by the webserver. Default value is 10.
 * **hsts** (Boolean) - Enables the sending of HTTP Strict Transport Security headers
 * **ignore_cache** (Boolean) - For development only. Disables the item cache.
+* **instances_social_key** - Key to the API of https://instances.social which retrieves data about mastodon servers.
 * **ipv4_resolve** (Boolean) - Resolve IPV4 addresses only. Don't resolve to IPV6. Default value is false.
 * **like_no_comment** (Boolean) - Don't update the "commented" value of an item when it is liked.
 * **local_block** (Boolean) - Used in conjunction with "block_public".
index feb4dfdc8dbe9aee53b9b6f1d1de20c1ef6d1b76..84bfd4c4f180978940814c4589f000e47def6dd6 100644 (file)
@@ -1343,14 +1343,17 @@ class PortableContact
 
                // Disvover Mastodon servers
                if (!Config::get('system', 'ostatus_disabled')) {
-                       $serverdata = fetch_url("https://instances.mastodon.xyz/instances.json");
-
-                       if ($serverdata) {
-                               $servers = json_decode($serverdata);
-
-                               foreach ($servers as $server) {
-                                       $url = (is_null($server->https_score) ? 'http' : 'https').'://'.$server->name;
-                                       Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $url);
+                       $accesstoken = Config::get('system', 'instances_social_key');
+                       if (!empty($accesstoken)) {
+                               $api = 'https://instances.social/api/1.0/instances/list?count=0';
+                               $header = array('Authorization: Bearer '.$accesstoken);
+                               $serverdata = z_fetch_url($api, false, $redirects, ['headers' => $header]);
+                               if ($serverdata['success']) {
+                                       $servers = json_decode($serverdata['body']);
+                                       foreach ($servers->instances as $server) {
+                                               $url = (is_null($server->https_score) ? 'http' : 'https').'://'.$server->name;
+                                               Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $url);
+                                       }
                                }
                        }
                }