Readded the network parameter

This commit is contained in:
Michael 2019-10-04 05:42:54 +00:00
parent d9a74bd5dd
commit a7e518acbd
4 changed files with 13 additions and 11 deletions

View File

@ -231,7 +231,7 @@ class GContact
}
// The server URL doesn't seem to be valid, so we don't store it.
if (!GServer::check($gcontact['server_url'])) {
if (!GServer::check($gcontact['server_url'], $gcontact['network'])) {
$gcontact['server_url'] = "";
}

View File

@ -25,7 +25,7 @@ use Friendica\Protocol\Diaspora;
*/
class GServer
{
public static function check($server_url, $force = false)
public static function check($server_url, $network = '', $force = false)
{
// Unify the server address
$server_url = trim($server_url, '/');
@ -57,13 +57,15 @@ class GServer
}
if (!$force && !PortableContact::updateNeeded($gserver['created'], '', $last_failure, $last_contact)) {
Logger::info('Use cached data', ['server' => $server_url]);
Logger::info('No update needed', ['server' => $server_url]);
return ($last_contact >= $last_failure);
}
Logger::info('Server is outdated. Start discovery.', ['Server' => $server_url, 'Force' => $force, 'Created' => $gserver['created'], 'Failure' => $last_failure, 'Contact' => $last_contact]);
} else {
Logger::info('Server is unknown. Start discovery.', ['Server' => $server_url]);
}
Logger::info('Server is outdated or unknown. Start discovery.', ['Server' => $server_url, 'Force' => $force, 'Created' => $gserver['created'], 'Failure' => $last_failure, 'Contact' => $last_contact]);
return self::detect($server_url);
return self::detect($server_url, $network);
}
/**
@ -74,7 +76,7 @@ class GServer
*
* @return boolean 'true' if server could be detected
*/
public static function detect($url)
public static function detect($url, $network = '')
{
$serverdata = [];

View File

@ -224,7 +224,7 @@ class PortableContact
return true;
}
return GServer::check($server, $force);
return GServer::check($server, $network, $force);
}
public static function alternateOStatusUrl($url)
@ -268,7 +268,7 @@ class PortableContact
}
if ($server_url != "") {
if (!GServer::check($server_url, $force)) {
if (!GServer::check($server_url, $gcontacts[0]["network"], $force)) {
if ($force) {
$fields = ['last_failure' => DateTimeFormat::utcNow()];
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($profile)]);
@ -705,7 +705,7 @@ class PortableContact
return true;
} else {
// If the server hadn't replied correctly, then force a sanity check
GServer::check($server["url"], true);
GServer::check($server["url"], $server["network"], true);
// If we couldn't reach the server, we will try it some time later
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
@ -740,7 +740,7 @@ class PortableContact
if (DBA::isResult($gservers)) {
foreach ($gservers as $gserver) {
if (!GServer::check($gserver['url'])) {
if (!GServer::check($gserver['url'], $gserver['network'])) {
// The server is not reachable? Okay, then we will try it later
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
DBA::update('gserver', $fields, ['nurl' => $gserver['nurl']]);

View File

@ -187,7 +187,7 @@ class DiscoverPoCo
$server_url = $user["server_url"];
}
if ((($server_url == "") && ($user["network"] == Protocol::FEED)) || $force_update || GServer::check($server_url)) {
if ((($server_url == "") && ($user["network"] == Protocol::FEED)) || $force_update || GServer::check($server_url, $user["network"])) {
Logger::log('Check profile '.$user["url"]);
Worker::add(PRIORITY_LOW, "DiscoverPoCo", "check_profile", $user["url"]);