reduce the number of network fetches for server detection of hubzilla/red systems from around 10 to maybe 5. Kind of wasteful to get hit on 10 non-existent endpoints every couple of minutes.

This commit is contained in:
zotlabs 2017-07-19 17:56:40 -07:00
parent 6f661d50dc
commit a583bda5fc

View file

@ -1160,6 +1160,29 @@ function poco_check_server($server_url, $network = "", $force = false) {
if (!$failure) {
// Test for Hubzilla, Redmatrix or Friendica
$serverret = z_fetch_url($server_url."/siteinfo.json");
if ($serverret["success"]) {
$data = json_decode($serverret["body"]);
if(isset($data->url)) {
$platform = $data->platform;
$version = $data->version;
$network = NETWORK_DIASPORA;
}
$site_name = $data->site_name;
switch ($data->register_policy) {
case "REGISTER_OPEN":
$register_policy = REGISTER_OPEN;
break;
case "REGISTER_APPROVE":
$register_policy = REGISTER_APPROVE;
break;
case "REGISTER_CLOSED":
default:
$register_policy = REGISTER_CLOSED;
break;
}
}
else {
$serverret = z_fetch_url($server_url."/api/statusnet/config.json");
if ($serverret["success"]) {
$data = json_decode($serverret["body"]);
@ -1211,6 +1234,7 @@ function poco_check_server($server_url, $network = "", $force = false) {
}
}
}
}
// Query statistics.json. Optional package for Diaspora, Friendica and Redmatrix
if (!$failure) {