mirror of
https://github.com/friendica/friendica
synced 2025-04-26 21:10:16 +00:00
Fix delivery problems with "reachable" test
This commit is contained in:
parent
20374ab5a2
commit
d39f4014e4
2 changed files with 35 additions and 23 deletions
|
@ -167,31 +167,43 @@ class GServer
|
|||
/**
|
||||
* Checks if the given server is reachable
|
||||
*
|
||||
* @param string $profile URL of the given profile
|
||||
* @param string $server URL of the given server (If empty, taken from profile)
|
||||
* @param string $network Network value that is used, when detection failed
|
||||
* @param boolean $force Force an update.
|
||||
* @param array $contact Contact that should be checked
|
||||
*
|
||||
* @return boolean 'true' if server seems vital
|
||||
*/
|
||||
public static function reachable(string $profile, string $server = '', string $network = '', bool $force = false): bool
|
||||
public static function reachable(array $contact): bool
|
||||
{
|
||||
if ($server == '') {
|
||||
$contact = Contact::getByURL($profile, null, ['baseurl', 'network']);
|
||||
if (!empty($contact['baseurl'])) {
|
||||
$server = $contact['baseurl'];
|
||||
} elseif ($contact['network'] == Protocol::DIASPORA) {
|
||||
$parts = parse_url($profile);
|
||||
unset($parts['path']);
|
||||
$server = (string)Uri::fromParts($parts);
|
||||
}
|
||||
}
|
||||
|
||||
if ($server == '') {
|
||||
if (!empty($contact['gsid'])) {
|
||||
$gsid = $contact['gsid'];
|
||||
} elseif (!empty($contact['baseurl'])) {
|
||||
$server = $contact['baseurl'];
|
||||
} elseif ($contact['network'] == Protocol::DIASPORA) {
|
||||
$parts = parse_url($contact['url']);
|
||||
unset($parts['path']);
|
||||
$server = (string)Uri::fromParts($parts);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
return self::check($server, $network, $force);
|
||||
if (!empty($gsid)) {
|
||||
$condition = ['id' => $gsid];
|
||||
} else {
|
||||
$condition = ['nurl' => Strings::normaliseLink($server)];
|
||||
}
|
||||
|
||||
$gserver = DBA::selectFirst('gserver', ['url', 'next_contact', 'failed'], $condition);
|
||||
if (empty($gserver)) {
|
||||
$reachable = true;
|
||||
} else {
|
||||
$reachable = !$gserver['failed'];
|
||||
$server = $gserver['url'];
|
||||
}
|
||||
|
||||
if (!empty($server) && (empty($gserver) || strtotime($gserver['next_contact']) < time())) {
|
||||
Worker::add(Worker::PRIORITY_LOW, 'UpdateGServer', $server, false);
|
||||
}
|
||||
|
||||
return $reachable;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue