New field "failed" for gserver, gcontact and contact
This commit is contained in:
parent
e67dbd9747
commit
1532f0d529
5 changed files with 47 additions and 32 deletions
|
@ -1029,7 +1029,7 @@ class Contact
|
||||||
{
|
{
|
||||||
// Always unarchive the relay contact entry
|
// Always unarchive the relay contact entry
|
||||||
if (!empty($contact['batch']) && !empty($contact['term-date']) && ($contact['term-date'] > DBA::NULL_DATETIME)) {
|
if (!empty($contact['batch']) && !empty($contact['term-date']) && ($contact['term-date'] > DBA::NULL_DATETIME)) {
|
||||||
$fields = ['term-date' => DBA::NULL_DATETIME, 'archive' => false];
|
$fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false];
|
||||||
$condition = ['uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => self::TYPE_RELAY];
|
$condition = ['uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => self::TYPE_RELAY];
|
||||||
DBA::update('contact', $fields, $condition);
|
DBA::update('contact', $fields, $condition);
|
||||||
}
|
}
|
||||||
|
@ -1053,7 +1053,7 @@ class Contact
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's a miracle. Our dead contact has inexplicably come back to life.
|
// It's a miracle. Our dead contact has inexplicably come back to life.
|
||||||
$fields = ['term-date' => DBA::NULL_DATETIME, 'archive' => false];
|
$fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false];
|
||||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||||
DBA::update('contact', $fields, ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
|
DBA::update('contact', $fields, ['nurl' => Strings::normaliseLink($contact['url']), 'self' => false]);
|
||||||
GContact::updateFromPublicContactURL($contact['url']);
|
GContact::updateFromPublicContactURL($contact['url']);
|
||||||
|
@ -1495,7 +1495,8 @@ class Contact
|
||||||
$updated = [
|
$updated = [
|
||||||
'url' => $data['url'],
|
'url' => $data['url'],
|
||||||
'nurl' => Strings::normaliseLink($data['url']),
|
'nurl' => Strings::normaliseLink($data['url']),
|
||||||
'updated' => DateTimeFormat::utcNow()
|
'updated' => DateTimeFormat::utcNow(),
|
||||||
|
'failed' => false
|
||||||
];
|
];
|
||||||
|
|
||||||
$fields = ['addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'baseurl', 'gsid'];
|
$fields = ['addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'baseurl', 'gsid'];
|
||||||
|
@ -1973,7 +1974,7 @@ class Contact
|
||||||
// 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($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, $contact['url'], ['last-update' => $updated, 'success_update' => $updated]);
|
self::updateContact($id, $uid, $contact['url'], ['failed' => false, 'last-update' => $updated, 'success_update' => $updated]);
|
||||||
Logger::info('Not updating relais', ['id' => $id, 'url' => $contact['url']]);
|
Logger::info('Not updating relais', ['id' => $id, 'url' => $contact['url']]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1981,7 +1982,7 @@ class Contact
|
||||||
// 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")
|
||||||
if (in_array($ret['network'], [Protocol::FEED, Protocol::PHANTOM]) && ($ret['network'] != $contact['network'])) {
|
if (in_array($ret['network'], [Protocol::FEED, Protocol::PHANTOM]) && ($ret['network'] != $contact['network'])) {
|
||||||
if ($force && ($uid == 0)) {
|
if ($force && ($uid == 0)) {
|
||||||
self::updateContact($id, $uid, $ret['url'], ['last-update' => $updated, 'failure_update' => $updated]);
|
self::updateContact($id, $uid, $ret['url'], ['failed' => true, 'last-update' => $updated, 'failure_update' => $updated]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2025,7 +2026,7 @@ class Contact
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
if ($force) {
|
if ($force) {
|
||||||
self::updateContact($id, $uid, $ret['url'], ['last-update' => $updated, 'success_update' => $updated]);
|
self::updateContact($id, $uid, $ret['url'], ['failed' => false, 'last-update' => $updated, 'success_update' => $updated]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the public contact
|
// Update the public contact
|
||||||
|
@ -2055,6 +2056,7 @@ class Contact
|
||||||
if ($force && ($uid == 0)) {
|
if ($force && ($uid == 0)) {
|
||||||
$ret['last-update'] = $updated;
|
$ret['last-update'] = $updated;
|
||||||
$ret['success_update'] = $updated;
|
$ret['success_update'] = $updated;
|
||||||
|
$ret['failed'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($ret['photo']);
|
unset($ret['photo']);
|
||||||
|
|
|
@ -231,6 +231,7 @@ class GContact
|
||||||
}
|
}
|
||||||
|
|
||||||
$gcontact['server_url'] = $data['baseurl'];
|
$gcontact['server_url'] = $data['baseurl'];
|
||||||
|
$gcontact['failed'] = false;
|
||||||
|
|
||||||
$gcontact = array_merge($gcontact, $data);
|
$gcontact = array_merge($gcontact, $data);
|
||||||
}
|
}
|
||||||
|
@ -642,7 +643,7 @@ class GContact
|
||||||
$fields = ['name' => $contact['name'], 'nick' => $contact['nick'] ?? '', 'addr' => $contact['addr'] ?? '', 'network' => $contact['network'],
|
$fields = ['name' => $contact['name'], 'nick' => $contact['nick'] ?? '', 'addr' => $contact['addr'] ?? '', 'network' => $contact['network'],
|
||||||
'url' => $contact['url'], 'nurl' => Strings::normaliseLink($contact['url']), 'photo' => $contact['photo'],
|
'url' => $contact['url'], 'nurl' => Strings::normaliseLink($contact['url']), 'photo' => $contact['photo'],
|
||||||
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(), 'location' => $contact['location'],
|
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(), 'location' => $contact['location'],
|
||||||
'about' => $contact['about'], 'hide' => $contact['hide'], 'generation' => $contact['generation']];
|
'about' => $contact['about'], 'hide' => $contact['hide'], 'generation' => $contact['generation'], 'failed' => false];
|
||||||
|
|
||||||
DBA::insert('gcontact', $fields);
|
DBA::insert('gcontact', $fields);
|
||||||
|
|
||||||
|
@ -681,7 +682,7 @@ class GContact
|
||||||
}
|
}
|
||||||
|
|
||||||
$public_contact = DBA::selectFirst('gcontact', [
|
$public_contact = DBA::selectFirst('gcontact', [
|
||||||
'name', 'nick', 'photo', 'location', 'about', 'addr', 'generation', 'birthday', 'keywords', 'gsid',
|
'name', 'nick', 'photo', 'location', 'about', 'addr', 'generation', 'birthday', 'keywords', 'gsid', 'failed',
|
||||||
'contact-type', 'hide', 'nsfw', 'network', 'alias', 'notify', 'server_url', 'connect', 'updated', 'url'
|
'contact-type', 'hide', 'nsfw', 'network', 'alias', 'notify', 'server_url', 'connect', 'updated', 'url'
|
||||||
], ['id' => $gcontact_id]);
|
], ['id' => $gcontact_id]);
|
||||||
|
|
||||||
|
@ -787,7 +788,7 @@ class GContact
|
||||||
'location' => $contact['location'], 'about' => $contact['about'],
|
'location' => $contact['location'], 'about' => $contact['about'],
|
||||||
'generation' => $contact['generation'], 'updated' => $contact['updated'],
|
'generation' => $contact['generation'], 'updated' => $contact['updated'],
|
||||||
'server_url' => $contact['server_url'], 'connect' => $contact['connect'],
|
'server_url' => $contact['server_url'], 'connect' => $contact['connect'],
|
||||||
'gsid' => $contact['gsid']
|
'failed' => $contact['failed'], 'gsid' => $contact['gsid']
|
||||||
];
|
];
|
||||||
|
|
||||||
DBA::update('gcontact', $updated, $condition, $fields);
|
DBA::update('gcontact', $updated, $condition, $fields);
|
||||||
|
@ -851,13 +852,13 @@ class GContact
|
||||||
$noscrape = json_decode($curlResult->getBody(), true);
|
$noscrape = json_decode($curlResult->getBody(), true);
|
||||||
if (!empty($noscrape) && !empty($noscrape['updated'])) {
|
if (!empty($noscrape) && !empty($noscrape['updated'])) {
|
||||||
$noscrape['updated'] = DateTimeFormat::utc($noscrape['updated'], DateTimeFormat::MYSQL);
|
$noscrape['updated'] = DateTimeFormat::utc($noscrape['updated'], DateTimeFormat::MYSQL);
|
||||||
$fields = ['last_contact' => DateTimeFormat::utcNow(), 'updated' => $noscrape['updated']];
|
$fields = ['failed' => false, 'last_contact' => DateTimeFormat::utcNow(), 'updated' => $noscrape['updated']];
|
||||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} elseif ($curlResult->isTimeout()) {
|
} elseif ($curlResult->isTimeout()) {
|
||||||
// On a timeout return the existing value, but mark the contact as failure
|
// On a timeout return the existing value, but mark the contact as failure
|
||||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
$fields = ['failed' => true, 'last_failure' => DateTimeFormat::utcNow()];
|
||||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -915,7 +916,7 @@ class GContact
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['last_contact' => DateTimeFormat::utcNow(), 'updated' => $last_updated];
|
$fields = ['failed' => false, 'last_contact' => DateTimeFormat::utcNow(), 'updated' => $last_updated];
|
||||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,7 +930,7 @@ class GContact
|
||||||
// Search for the newest entry in the feed
|
// Search for the newest entry in the feed
|
||||||
$curlResult = Network::curl($data['poll']);
|
$curlResult = Network::curl($data['poll']);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
$fields = ['failed' => true, 'last_failure' => DateTimeFormat::utcNow()];
|
||||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
||||||
|
|
||||||
Logger::info("Profile wasn't reachable (no feed)", ['url' => $data['url']]);
|
Logger::info("Profile wasn't reachable (no feed)", ['url' => $data['url']]);
|
||||||
|
@ -970,7 +971,7 @@ class GContact
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['last_contact' => DateTimeFormat::utcNow(), 'updated' => $last_updated];
|
$fields = ['failed' => false, 'last_contact' => DateTimeFormat::utcNow(), 'updated' => $last_updated];
|
||||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($data['url'])]);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1012,7 +1013,7 @@ class GContact
|
||||||
$fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords',
|
$fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords',
|
||||||
'bd', 'contact-type', 'network', 'addr', 'notify', 'alias', 'archive', 'term-date',
|
'bd', 'contact-type', 'network', 'addr', 'notify', 'alias', 'archive', 'term-date',
|
||||||
'created', 'updated', 'avatar', 'success_update', 'failure_update', 'forum', 'prv',
|
'created', 'updated', 'avatar', 'success_update', 'failure_update', 'forum', 'prv',
|
||||||
'baseurl', 'gsid', 'sensitive', 'unsearchable'];
|
'baseurl', 'gsid', 'sensitive', 'unsearchable', 'failed'];
|
||||||
|
|
||||||
$contact = DBA::selectFirst('contact', $fields, array_merge($condition, ['uid' => 0, 'network' => Protocol::FEDERATED]));
|
$contact = DBA::selectFirst('contact', $fields, array_merge($condition, ['uid' => 0, 'network' => Protocol::FEDERATED]));
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
|
@ -1022,7 +1023,7 @@ class GContact
|
||||||
$fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords', 'generation',
|
$fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords', 'generation',
|
||||||
'birthday', 'contact-type', 'network', 'addr', 'notify', 'alias', 'archived', 'archive_date',
|
'birthday', 'contact-type', 'network', 'addr', 'notify', 'alias', 'archived', 'archive_date',
|
||||||
'created', 'updated', 'photo', 'last_contact', 'last_failure', 'community', 'connect',
|
'created', 'updated', 'photo', 'last_contact', 'last_failure', 'community', 'connect',
|
||||||
'server_url', 'gsid', 'nsfw', 'hide', 'id'];
|
'server_url', 'gsid', 'nsfw', 'hide', 'id', 'failed'];
|
||||||
|
|
||||||
$old_gcontact = DBA::selectFirst('gcontact', $fields, ['nurl' => $contact['nurl']]);
|
$old_gcontact = DBA::selectFirst('gcontact', $fields, ['nurl' => $contact['nurl']]);
|
||||||
$do_insert = !DBA::isResult($old_gcontact);
|
$do_insert = !DBA::isResult($old_gcontact);
|
||||||
|
@ -1034,7 +1035,7 @@ class GContact
|
||||||
|
|
||||||
// These fields are identical in both contact and gcontact
|
// These fields are identical in both contact and gcontact
|
||||||
$fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords', 'gsid',
|
$fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords', 'gsid',
|
||||||
'contact-type', 'network', 'addr', 'notify', 'alias', 'created', 'updated'];
|
'contact-type', 'network', 'addr', 'notify', 'alias', 'created', 'updated', 'failed'];
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$gcontact[$field] = $contact[$field];
|
$gcontact[$field] = $contact[$field];
|
||||||
|
@ -1100,13 +1101,14 @@ class GContact
|
||||||
$data = Probe::uri($url, $force);
|
$data = Probe::uri($url, $force);
|
||||||
|
|
||||||
if (in_array($data['network'], [Protocol::PHANTOM])) {
|
if (in_array($data['network'], [Protocol::PHANTOM])) {
|
||||||
$fields = ['last_failure' => DateTimeFormat::utcNow()];
|
$fields = ['failed' => true, 'last_failure' => DateTimeFormat::utcNow()];
|
||||||
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($url)]);
|
DBA::update('gcontact', $fields, ['nurl' => Strings::normaliseLink($url)]);
|
||||||
Logger::info('Invalid network for contact', ['url' => $data['url'], 'callstack' => System::callstack()]);
|
Logger::info('Invalid network for contact', ['url' => $data['url'], 'callstack' => System::callstack()]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['server_url'] = $data['baseurl'];
|
$data['server_url'] = $data['baseurl'];
|
||||||
|
$data['failed'] = false;
|
||||||
|
|
||||||
self::update($data);
|
self::update($data);
|
||||||
|
|
||||||
|
|
|
@ -235,14 +235,14 @@ class GServer
|
||||||
private static function setFailure(string $url)
|
private static function setFailure(string $url)
|
||||||
{
|
{
|
||||||
if (DBA::exists('gserver', ['nurl' => Strings::normaliseLink($url)])) {
|
if (DBA::exists('gserver', ['nurl' => Strings::normaliseLink($url)])) {
|
||||||
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow(), 'detection-method' => null],
|
DBA::update('gserver', ['failed' => true, 'last_failure' => DateTimeFormat::utcNow(), 'detection-method' => null],
|
||||||
['nurl' => Strings::normaliseLink($url)]);
|
['nurl' => Strings::normaliseLink($url)]);
|
||||||
Logger::info('Set failed status for existing server', ['url' => $url]);
|
Logger::info('Set failed status for existing server', ['url' => $url]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DBA::insert('gserver', ['url' => $url, 'nurl' => Strings::normaliseLink($url),
|
DBA::insert('gserver', ['url' => $url, 'nurl' => Strings::normaliseLink($url),
|
||||||
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
|
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
|
||||||
'last_failure' => DateTimeFormat::utcNow()]);
|
'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
|
||||||
Logger::info('Set failed status for new server', ['url' => $url]);
|
Logger::info('Set failed status for new server', ['url' => $url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +303,8 @@ class GServer
|
||||||
|
|
||||||
// If the URL missmatches, then we mark the old entry as failure
|
// If the URL missmatches, then we mark the old entry as failure
|
||||||
if ($url != $original_url) {
|
if ($url != $original_url) {
|
||||||
DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => Strings::normaliseLink($original_url)]);
|
DBA::update('gserver', ['failed' => true, 'last_failure' => DateTimeFormat::utcNow()],
|
||||||
|
['nurl' => Strings::normaliseLink($original_url)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When a nodeinfo is present, we don't need to dig further
|
// When a nodeinfo is present, we don't need to dig further
|
||||||
|
@ -449,6 +450,7 @@ class GServer
|
||||||
}
|
}
|
||||||
|
|
||||||
$serverdata['last_contact'] = DateTimeFormat::utcNow();
|
$serverdata['last_contact'] = DateTimeFormat::utcNow();
|
||||||
|
$serverdata['failed'] = false;
|
||||||
|
|
||||||
$gserver = DBA::selectFirst('gserver', ['network'], ['nurl' => Strings::normaliseLink($url)]);
|
$gserver = DBA::selectFirst('gserver', ['network'], ['nurl' => Strings::normaliseLink($url)]);
|
||||||
if (!DBA::isResult($gserver)) {
|
if (!DBA::isResult($gserver)) {
|
||||||
|
|
|
@ -165,7 +165,7 @@ class OnePoll
|
||||||
if (!strstr($xml, '<')) {
|
if (!strstr($xml, '<')) {
|
||||||
Logger::log('post_handshake: response from ' . $url . ' did not contain XML.');
|
Logger::log('post_handshake: response from ' . $url . ' did not contain XML.');
|
||||||
|
|
||||||
$fields = ['last-update' => $updated, 'failure_update' => $updated];
|
$fields = ['failed' => true, 'last-update' => $updated, 'failure_update' => $updated];
|
||||||
self::updateContact($contact, $fields);
|
self::updateContact($contact, $fields);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
return;
|
return;
|
||||||
|
@ -213,10 +213,10 @@ class OnePoll
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
|
self::updateContact($contact, ['failed' => false, 'last-update' => $updated, 'success_update' => $updated]);
|
||||||
Contact::unmarkForArchival($contact);
|
Contact::unmarkForArchival($contact);
|
||||||
} elseif (in_array($contact["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED])) {
|
} elseif (in_array($contact["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED])) {
|
||||||
self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
|
self::updateContact($contact, ['failed' => true, 'last-update' => $updated, 'failure_update' => $updated]);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
} else {
|
} else {
|
||||||
self::updateContact($contact, ['last-update' => $updated]);
|
self::updateContact($contact, ['last-update' => $updated]);
|
||||||
|
@ -244,8 +244,14 @@ class OnePoll
|
||||||
*/
|
*/
|
||||||
private static function updateContact(array $contact, array $fields)
|
private static function updateContact(array $contact, array $fields)
|
||||||
{
|
{
|
||||||
|
// Update the user's contact
|
||||||
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
DBA::update('contact', $fields, ['id' => $contact['id']]);
|
||||||
|
|
||||||
|
// Update the public contact
|
||||||
DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
|
DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
|
||||||
|
|
||||||
|
// Update the rest of the contacts that aren't polled
|
||||||
|
DBA::update('contact', $fields, ['rel' => Contact::FOLLOWER, 'nurl' => $contact['nurl']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -289,7 +295,7 @@ class OnePoll
|
||||||
|
|
||||||
if (!$curlResult->isSuccess() && ($curlResult->getErrorNumber() == CURLE_OPERATION_TIMEDOUT)) {
|
if (!$curlResult->isSuccess() && ($curlResult->getErrorNumber() == CURLE_OPERATION_TIMEDOUT)) {
|
||||||
// set the last-update so we don't keep polling
|
// set the last-update so we don't keep polling
|
||||||
self::updateContact($contact, ['last-update' => $updated]);
|
self::updateContact($contact, ['failed' => true, 'last-update' => $updated]);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
Logger::log('Contact archived');
|
Logger::log('Contact archived');
|
||||||
return false;
|
return false;
|
||||||
|
@ -307,7 +313,7 @@ class OnePoll
|
||||||
Logger::log("$url appears to be dead - marking for death ");
|
Logger::log("$url appears to be dead - marking for death ");
|
||||||
|
|
||||||
// set the last-update so we don't keep polling
|
// set the last-update so we don't keep polling
|
||||||
$fields = ['last-update' => $updated, 'failure_update' => $updated];
|
$fields = ['failed' => true, 'last-update' => $updated, 'failure_update' => $updated];
|
||||||
self::updateContact($contact, $fields);
|
self::updateContact($contact, $fields);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
return false;
|
return false;
|
||||||
|
@ -316,7 +322,7 @@ class OnePoll
|
||||||
if (!strstr($handshake_xml, '<')) {
|
if (!strstr($handshake_xml, '<')) {
|
||||||
Logger::log('response from ' . $url . ' did not contain XML.');
|
Logger::log('response from ' . $url . ' did not contain XML.');
|
||||||
|
|
||||||
$fields = ['last-update' => $updated, 'failure_update' => $updated];
|
$fields = ['failed' => true, 'last-update' => $updated, 'failure_update' => $updated];
|
||||||
self::updateContact($contact, $fields);
|
self::updateContact($contact, $fields);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
return false;
|
return false;
|
||||||
|
@ -327,7 +333,7 @@ class OnePoll
|
||||||
if (!is_object($res)) {
|
if (!is_object($res)) {
|
||||||
Logger::info('Unparseable response', ['url' => $url]);
|
Logger::info('Unparseable response', ['url' => $url]);
|
||||||
|
|
||||||
$fields = ['last-update' => $updated, 'failure_update' => $updated];
|
$fields = ['failed' => true, 'last-update' => $updated, 'failure_update' => $updated];
|
||||||
self::updateContact($contact, $fields);
|
self::updateContact($contact, $fields);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
return false;
|
return false;
|
||||||
|
@ -338,7 +344,7 @@ class OnePoll
|
||||||
Logger::log("$url replied status 1 - marking for death ");
|
Logger::log("$url replied status 1 - marking for death ");
|
||||||
|
|
||||||
// set the last-update so we don't keep polling
|
// set the last-update so we don't keep polling
|
||||||
$fields = ['last-update' => $updated, 'failure_update' => $updated];
|
$fields = ['failed' => true, 'last-update' => $updated, 'failure_update' => $updated];
|
||||||
self::updateContact($contact, $fields);
|
self::updateContact($contact, $fields);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
} elseif ($contact['term-date'] > DBA::NULL_DATETIME) {
|
} elseif ($contact['term-date'] > DBA::NULL_DATETIME) {
|
||||||
|
@ -417,7 +423,7 @@ class OnePoll
|
||||||
// Will only do this once per notify-enabled OStatus contact
|
// Will only do this once per notify-enabled OStatus contact
|
||||||
// or if relationship changes
|
// or if relationship changes
|
||||||
|
|
||||||
$stat_writeable = ((($contact['notify']) && ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND)) ? 1 : 0);
|
$stat_writeable = $contact['notify'] && ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND);
|
||||||
|
|
||||||
// Contacts from OStatus are always writable
|
// Contacts from OStatus are always writable
|
||||||
if ($protocol === Protocol::OSTATUS) {
|
if ($protocol === Protocol::OSTATUS) {
|
||||||
|
@ -443,7 +449,7 @@ class OnePoll
|
||||||
|
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
// set the last-update so we don't keep polling
|
// set the last-update so we don't keep polling
|
||||||
self::updateContact($contact, ['last-update' => $updated]);
|
self::updateContact($contact, ['failed' => true, 'last-update' => $updated]);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
Logger::log('Contact archived');
|
Logger::log('Contact archived');
|
||||||
return false;
|
return false;
|
||||||
|
@ -467,7 +473,7 @@ class OnePoll
|
||||||
$mail_disabled = ((function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) ? 0 : 1);
|
$mail_disabled = ((function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) ? 0 : 1);
|
||||||
if ($mail_disabled) {
|
if ($mail_disabled) {
|
||||||
// set the last-update so we don't keep polling
|
// set the last-update so we don't keep polling
|
||||||
self::updateContact($contact, ['last-update' => $updated]);
|
self::updateContact($contact, ['failed' => true, 'last-update' => $updated]);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
Logger::log('Contact archived');
|
Logger::log('Contact archived');
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -82,6 +82,7 @@ return [
|
||||||
"last_poco_query" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"last_poco_query" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
"last_contact" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"last_contact" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
"last_failure" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"last_failure" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
|
"failed" => ["type" => "boolean", "comment" => "Connection failed"],
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["id"],
|
"PRIMARY" => ["id"],
|
||||||
|
@ -151,6 +152,7 @@ return [
|
||||||
"last-update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last try to update the contact info"],
|
"last-update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last try to update the contact info"],
|
||||||
"success_update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last successful contact update"],
|
"success_update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last successful contact update"],
|
||||||
"failure_update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last failed update"],
|
"failure_update" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last failed update"],
|
||||||
|
"failed" => ["type" => "boolean", "comment" => "Connection failed"],
|
||||||
"name-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"name-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
"uri-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"uri-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
"avatar-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"avatar-date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
|
@ -558,6 +560,7 @@ return [
|
||||||
"last_contact" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"last_contact" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
"last_failure" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"last_failure" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
"last_discovery" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last contact discovery"],
|
"last_discovery" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last contact discovery"],
|
||||||
|
"failed" => ["type" => "boolean", "comment" => "Connection failed"],
|
||||||
"archive_date" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
"archive_date" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => ""],
|
||||||
"archived" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
"archived" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
|
||||||
"location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
"location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
|
|
Loading…
Reference in a new issue