}
// 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'] = "";
}
*/
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, '/');
}
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);
}
/**
*
* @return boolean 'true' if server could be detected
*/
- public static function detect($url)
+ public static function detect($url, $network = '')
{
$serverdata = [];
return true;
}
- return GServer::check($server, $force);
+ return GServer::check($server, $network, $force);
}
public static function alternateOStatusUrl($url)
}
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)]);
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()];
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']]);
$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"]);