Merge pull request #14002 from annando/relais-update

Fix handling of relay contact updates
This commit is contained in:
Hypolite Petovan 2024-03-16 15:07:16 +00:00 committed by GitHub
commit 7615a3103f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2819,13 +2819,19 @@ class Contact
} }
// We must not try to update relay contacts via probe. They are no real contacts. // We must not try to update relay contacts via probe. They are no real contacts.
// See Relay::updateContact() for more details.
// We check after the probing to be able to correct falsely detected contact types. // We check after the probing to be able to correct falsely detected contact types.
if (($contact['contact-type'] == self::TYPE_RELAY) && if (($contact['contact-type'] == self::TYPE_RELAY) && Strings::compareLink($contact['url'], $contact['baseurl']) &&
(!Strings::compareLink($ret['url'], $contact['url']) || in_array($ret['network'], [Protocol::FEED, Protocol::PHANTOM])) (!Strings::compareLink($ret['url'], $contact['url']) || in_array($ret['network'], [Protocol::FEED, Protocol::PHANTOM]))
) { ) {
self::updateContact($id, $uid, $uriid, $contact['url'], ['failed' => false, 'local-data' => $has_local_data, 'last-update' => $updated, 'next-update' => $success_next_update, 'success_update' => $updated]); if (GServer::reachable($contact)) {
Logger::info('Not updating relais', ['id' => $id, 'url' => $contact['url']]); self::updateContact($id, $uid, $uriid, $contact['url'], ['failed' => false, 'local-data' => $has_local_data, 'last-update' => $updated, 'next-update' => $success_next_update, 'success_update' => $updated, 'unsearchable' => true]);
return true; Logger::info('Not updating relay', ['id' => $id, 'url' => $contact['url']]);
return true;
}
Logger::info('Relay server is not reachable', ['id' => $id, 'url' => $contact['url']]);
self::updateContact($id, $uid, $uriid, $contact['url'], ['failed' => true, 'local-data' => $has_local_data, 'last-update' => $updated, 'next-update' => $failed_next_update, 'failure_update' => $updated, 'unsearchable' => true]);
return false;
} }
// If Probe::uri fails the network code will be different ("feed" or "unkn") // If Probe::uri fails the network code will be different ("feed" or "unkn")