Logger::log('Start for contact ' . $contact_id);
- $force = false;
+ $force = false;
if ($command == "force") {
$force = true;
return;
}
+ if ($force) {
+ Contact::updateFromProbe($contact_id, true);
+ }
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
if (!DBA::isResult($contact)) {
$importer_uid = $contact['uid'];
- // Possibly switch the remote contact to AP
- if ($protocol === Protocol::OSTATUS) {
- ActivityPub\Receiver::switchContact($contact['id'], $importer_uid, $contact['url']);
- $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
- }
-
$updated = DateTimeFormat::utcNow();
- // These three networks can be able to speak AP, so we are trying to fetch AP profile data here
- if (in_array($protocol, [Protocol::ACTIVITYPUB, Protocol::DIASPORA, Protocol::DFRN])) {
- $apcontact = APContact::getByURL($contact['url'], true);
-
- if (($protocol === Protocol::ACTIVITYPUB) && empty($apcontact)) {
- self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
- Contact::markForArchival($contact);
- Logger::log('Contact archived');
- return;
- } elseif (!empty($apcontact)) {
- $fields = ['last-update' => $updated, 'success_update' => $updated];
- self::updateContact($contact, $fields);
- Contact::unmarkForArchival($contact);
- }
- }
-
- // Diaspora users, archived users and followers are only checked if they still exist.
- if (($protocol != Protocol::ACTIVITYPUB) && ($contact['archive'] || ($contact["network"] == Protocol::DIASPORA) || ($contact["rel"] == Contact::FOLLOWER))) {
- $last_updated = PortableContact::lastUpdated($contact["url"], true);
-
- if ($last_updated) {
- Logger::log('Contact '.$contact['id'].' had last update on '.$last_updated, Logger::DEBUG);
-
- // The last public item can be older than the last item we got
- if ($last_updated < $contact['last-item']) {
- $last_updated = $contact['last-item'];
- }
+ if ($importer_uid == 0) {
+ Logger::log('Ignore public contacts');
- $fields = ['last-item' => DateTimeFormat::utc($last_updated), 'last-update' => $updated, 'success_update' => $updated];
- self::updateContact($contact, $fields);
- Contact::unmarkForArchival($contact);
- } else {
- self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
- Contact::markForArchival($contact);
- Logger::log('Contact archived');
- return;
- }
+ // set the last-update so we don't keep polling
+ DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
+ return;
}
- // Update the contact entry
- if (in_array($protocol, [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN])) {
- // Currently we can't check every AP implementation, so we don't do it at all
- if (($protocol != Protocol::ACTIVITYPUB) && !PortableContact::reachable($contact['url'])) {
- Logger::log("Skipping probably dead contact ".$contact['url']);
-
- // set the last-update so we don't keep polling
- self::updateContact($contact, ['last-update' => $updated]);
- return;
- }
-
- if (!Contact::updateFromProbe($contact["id"])) {
- // set the last-update so we don't keep polling
- self::updateContact($contact, ['last-update' => $updated]);
- Contact::markForArchival($contact);
- Logger::log('Contact archived');
- return;
- } else {
- $fields = ['last-update' => $updated, 'success_update' => $updated];
- self::updateContact($contact, $fields);
- Contact::unmarkForArchival($contact);
- }
+ // Possibly switch the remote contact to AP
+ if ($protocol === Protocol::OSTATUS) {
+ ActivityPub\Receiver::switchContact($contact['id'], $importer_uid, $contact['url']);
+ $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
}
// load current friends if possible.
}
}
- // We don't poll our followers
- if ($contact["rel"] == Contact::FOLLOWER) {
- Logger::log("Don't poll follower");
-
- // set the last-update so we don't keep polling
- DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
- return;
- }
-
// Don't poll if polling is deactivated (But we poll feeds and mails anyway)
if (!in_array($protocol, [Protocol::FEED, Protocol::MAIL]) && Config::get('system', 'disable_polling')) {
Logger::log('Polling is disabled');
return;
}
- if ($importer_uid == 0) {
- Logger::log('Ignore public contacts');
-
- // set the last-update so we don't keep polling
- DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
- return;
- }
-
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($importer_uid)
);