Merge pull request #4022 from annando/instances_social

Retrieve data about Mastodon servers
This commit is contained in:
Hypolite Petovan 2017-12-06 15:36:22 -05:00 committed by GitHub
commit 311af3e544
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View 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. * **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 * **hsts** (Boolean) - Enables the sending of HTTP Strict Transport Security headers
* **ignore_cache** (Boolean) - For development only. Disables the item cache. * **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. See https://instances.social/api/token to get an API key.
* **ipv4_resolve** (Boolean) - Resolve IPV4 addresses only. Don't resolve to IPV6. Default value is false. * **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. * **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". * **local_block** (Boolean) - Used in conjunction with "block_public".

View File

@ -1343,17 +1343,20 @@ class PortableContact
// Disvover Mastodon servers // Disvover Mastodon servers
if (!Config::get('system', 'ostatus_disabled')) { if (!Config::get('system', 'ostatus_disabled')) {
$serverdata = fetch_url("https://instances.mastodon.xyz/instances.json"); $accesstoken = Config::get('system', 'instances_social_key');
if (!empty($accesstoken)) {
if ($serverdata) { $api = 'https://instances.social/api/1.0/instances/list?count=0';
$servers = json_decode($serverdata); $header = array('Authorization: Bearer '.$accesstoken);
$serverdata = z_fetch_url($api, false, $redirects, ['headers' => $header]);
foreach ($servers as $server) { if ($serverdata['success']) {
$servers = json_decode($serverdata['body']);
foreach ($servers->instances as $server) {
$url = (is_null($server->https_score) ? 'http' : 'https').'://'.$server->name; $url = (is_null($server->https_score) ? 'http' : 'https').'://'.$server->name;
Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $url); Worker::add(PRIORITY_LOW, "DiscoverPoCo", "server", $url);
} }
} }
} }
}
// Currently disabled, since the service isn't available anymore. // Currently disabled, since the service isn't available anymore.
// It is not removed since I hope that there will be a successor. // It is not removed since I hope that there will be a successor.