|
|
|
|
@@ -15,6 +15,7 @@ use Friendica\Protocol\PortableContact;
|
|
|
|
|
use Friendica\Util\Network;
|
|
|
|
|
use Friendica\Util\XML;
|
|
|
|
|
use Friendica\Util\Temporal;
|
|
|
|
|
use Friendica\Util\DateTimeFormat;
|
|
|
|
|
use dba;
|
|
|
|
|
|
|
|
|
|
require_once 'include/dba.php';
|
|
|
|
|
@@ -44,7 +45,7 @@ class OnePoll
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$d = Temporal::utcNow();
|
|
|
|
|
$d = DateTimeFormat::utcNow();
|
|
|
|
|
|
|
|
|
|
$contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
|
|
|
|
|
if (!DBM::is_result($contact)) {
|
|
|
|
|
@@ -70,7 +71,7 @@ class OnePoll
|
|
|
|
|
// Diaspora users, archived users and followers are only checked if they still exist.
|
|
|
|
|
if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
|
|
|
|
|
$last_updated = PortableContact::lastUpdated($contact["url"], true);
|
|
|
|
|
$updated = Temporal::utcNow();
|
|
|
|
|
$updated = DateTimeFormat::utcNow();
|
|
|
|
|
if ($last_updated) {
|
|
|
|
|
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
|
|
|
|
|
|
|
|
|
|
@@ -99,7 +100,7 @@ class OnePoll
|
|
|
|
|
$contact['priority'] = intval($poll_interval);
|
|
|
|
|
$hub_update = false;
|
|
|
|
|
|
|
|
|
|
if (Temporal::utcNow() > Temporal::utc($t . " + 1 day")) {
|
|
|
|
|
if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 day")) {
|
|
|
|
|
$hub_update = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
@@ -107,8 +108,8 @@ class OnePoll
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$last_update = (($contact['last-update'] <= NULL_DATE)
|
|
|
|
|
? Temporal::utc('now - 7 days', Temporal::ATOM)
|
|
|
|
|
: Temporal::utc($contact['last-update'], Temporal::ATOM)
|
|
|
|
|
? DateTimeFormat::utc('now - 7 days', DateTimeFormat::ATOM)
|
|
|
|
|
: DateTimeFormat::utc($contact['last-update'], DateTimeFormat::ATOM)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Update the contact entry
|
|
|
|
|
@@ -117,7 +118,7 @@ class OnePoll
|
|
|
|
|
logger("Skipping probably dead contact ".$contact['url']);
|
|
|
|
|
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -126,7 +127,7 @@ class OnePoll
|
|
|
|
|
logger('Contact is marked dead');
|
|
|
|
|
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
Contact::unmarkForArchival($contact);
|
|
|
|
|
@@ -137,7 +138,7 @@ class OnePoll
|
|
|
|
|
logger('Ignore public contacts');
|
|
|
|
|
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -149,7 +150,7 @@ class OnePoll
|
|
|
|
|
logger('No self contact for user '.$importer_uid);
|
|
|
|
|
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -185,7 +186,7 @@ class OnePoll
|
|
|
|
|
|
|
|
|
|
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
Contact::markForArchival($contact);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -207,7 +208,7 @@ class OnePoll
|
|
|
|
|
Contact::markForArchival($contact);
|
|
|
|
|
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
|
|
|
|
|
$fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
|
|
|
|
|
self::updateContact($contact, $fields);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -217,7 +218,7 @@ class OnePoll
|
|
|
|
|
|
|
|
|
|
Contact::markForArchival($contact);
|
|
|
|
|
|
|
|
|
|
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
|
|
|
|
|
$fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
|
|
|
|
|
self::updateContact($contact, $fields);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -230,7 +231,7 @@ class OnePoll
|
|
|
|
|
|
|
|
|
|
// we may not be friends anymore. Will keep trying for one month.
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
|
|
|
|
|
$fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
|
|
|
|
|
self::updateContact($contact, $fields);
|
|
|
|
|
|
|
|
|
|
Contact::markForArchival($contact);
|
|
|
|
|
@@ -241,7 +242,7 @@ class OnePoll
|
|
|
|
|
|
|
|
|
|
if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -276,7 +277,7 @@ class OnePoll
|
|
|
|
|
logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
|
|
|
|
|
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
Contact::markForArchival($contact);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -311,7 +312,7 @@ class OnePoll
|
|
|
|
|
|
|
|
|
|
if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) {
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -321,7 +322,7 @@ class OnePoll
|
|
|
|
|
|
|
|
|
|
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
Contact::markForArchival($contact);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -335,7 +336,7 @@ class OnePoll
|
|
|
|
|
$mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
|
|
|
|
|
if ($mail_disabled) {
|
|
|
|
|
// set the last-update so we don't keep polling
|
|
|
|
|
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
|
|
|
|
|
Contact::markForArchival($contact);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -355,7 +356,7 @@ class OnePoll
|
|
|
|
|
unset($password);
|
|
|
|
|
logger("Mail: Connect to " . $mailconf['user']);
|
|
|
|
|
if ($mbox) {
|
|
|
|
|
$fields = ['last_check' => Temporal::utcNow()];
|
|
|
|
|
$fields = ['last_check' => DateTimeFormat::utcNow()];
|
|
|
|
|
dba::update('mailacct', $fields, ['id' => $mailconf['id']]);
|
|
|
|
|
logger("Mail: Connected to " . $mailconf['user']);
|
|
|
|
|
} else {
|
|
|
|
|
@@ -395,7 +396,7 @@ class OnePoll
|
|
|
|
|
// Only delete when mails aren't automatically moved or deleted
|
|
|
|
|
if (($mailconf['action'] != 1) && ($mailconf['action'] != 3))
|
|
|
|
|
if ($meta->deleted && ! $item['deleted']) {
|
|
|
|
|
$fields = ['deleted' => true, 'changed' => Temporal::utcNow()];
|
|
|
|
|
$fields = ['deleted' => true, 'changed' => DateTimeFormat::utcNow()];
|
|
|
|
|
dba::update('item', $fields, ['id' => $item['id']]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -459,7 +460,7 @@ class OnePoll
|
|
|
|
|
$datarray['title'] = notags(trim($datarray['title']));
|
|
|
|
|
|
|
|
|
|
//$datarray['title'] = notags(trim($meta->subject));
|
|
|
|
|
$datarray['created'] = Temporal::utc($meta->date);
|
|
|
|
|
$datarray['created'] = DateTimeFormat::utc($meta->date);
|
|
|
|
|
|
|
|
|
|
// Is it a reply?
|
|
|
|
|
$reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") ||
|
|
|
|
|
@@ -572,7 +573,7 @@ class OnePoll
|
|
|
|
|
if (!strstr($xml, '<')) {
|
|
|
|
|
logger('post_handshake: response from ' . $url . ' did not contain XML.');
|
|
|
|
|
|
|
|
|
|
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
|
|
|
|
|
$fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
|
|
|
|
|
self::updateContact($contact, $fields);
|
|
|
|
|
Contact::markForArchival($contact);
|
|
|
|
|
return;
|
|
|
|
|
@@ -616,19 +617,19 @@ class OnePoll
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$updated = Temporal::utcNow();
|
|
|
|
|
$updated = DateTimeFormat::utcNow();
|
|
|
|
|
|
|
|
|
|
self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
|
|
|
|
|
dba::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
|
|
|
|
|
Contact::unmarkForArchival($contact);
|
|
|
|
|
} elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) {
|
|
|
|
|
$updated = Temporal::utcNow();
|
|
|
|
|
$updated = DateTimeFormat::utcNow();
|
|
|
|
|
|
|
|
|
|
self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
|
|
|
|
|
dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]);
|
|
|
|
|
Contact::markForArchival($contact);
|
|
|
|
|
} else {
|
|
|
|
|
$updated = Temporal::utcNow();
|
|
|
|
|
$updated = DateTimeFormat::utcNow();
|
|
|
|
|
dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|