<?php
+/**
+ * @file src/Worker/OnePoll.php
+ */
namespace Friendica\Worker;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
+use Friendica\Object\Contact;
+use Friendica\Protocol\PortableContact;
use dba;
require_once 'include/follow.php';
-Class OnePoll {
+Class OnePoll
+{
public static function execute($contact_id = 0, $command = '') {
global $a;
require_once 'include/datetime.php';
require_once 'include/items.php';
- require_once 'include/Contact.php';
require_once 'include/email.php';
- require_once 'include/socgraph.php';
require_once 'include/queue_fn.php';
logger('onepoll: start');
);
if (DBM::is_result($r)) {
if (!$r[0]['total']) {
- poco_load($contact['id'], $importer_uid, 0, $contact['poco']);
+ PortableContact::loadWorker($contact['id'], $importer_uid, 0, $contact['poco']);
}
}
}
/// @TODO Check why we don't poll the Diaspora feed at the moment (some guid problem in the items?)
/// @TODO Check whether this is possible with Redmatrix
if ($contact["network"] == NETWORK_DIASPORA) {
- if (poco_do_update($contact["created"], $contact["last-item"], $contact["failure_update"], $contact["success_update"])) {
- $last_updated = poco_last_updated($contact["url"]);
+ if (PortableContact::updateNeeded($contact["created"], $contact["last-item"], $contact["failure_update"], $contact["success_update"])) {
+ $last_updated = PortableContact::lastUpdated($contact["url"]);
$updated = datetime_convert();
if ($last_updated) {
$fields = array('last-item' => $last_updated, 'last-update' => $updated, 'success_update' => $updated);
// Update the contact entry
if (($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) {
- if (!poco_reachable($contact['url'])) {
+ if (!PortableContact::reachable($contact['url'])) {
logger("Skipping probably dead contact ".$contact['url']);
return;
}
if (!update_contact($contact["id"])) {
- mark_for_death($contact);
+ Contact::markForArchival($contact);
logger('Contact is marked dead');
return;
} else {
- unmark_for_death($contact);
+ Contact::unmarkForArchival($contact);
}
}
if (!strlen($handshake_xml) || ($html_code >= 400) || !$html_code) {
- logger("poller: $url appears to be dead - marking for death ");
+ logger("$url appears to be dead - marking for death ");
// dead connection - might be a transient event, or this might
// mean the software was uninstalled or the domain expired.
// Will keep trying for one month.
- mark_for_death($contact);
+ Contact::markForArchival($contact);
// set the last-update so we don't keep polling
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
}
if (!strstr($handshake_xml, '<')) {
- logger('poller: response from ' . $url . ' did not contain XML.');
+ logger('response from ' . $url . ' did not contain XML.');
- mark_for_death($contact);
+ Contact::markForArchival($contact);
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
dba::update('contact', $fields, array('id' => $contact['id']));
$res = parse_xml_string($handshake_xml);
if (intval($res->status) == 1) {
- logger("poller: $url replied status 1 - marking for death ");
+ logger("$url replied status 1 - marking for death ");
// we may not be friends anymore. Will keep trying for one month.
// set the last-update so we don't keep polling
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
dba::update('contact', $fields, array('id' => $contact['id']));
- mark_for_death($contact);
+ Contact::markForArchival($contact);
} elseif ($contact['term-date'] > NULL_DATE) {
- logger("poller: $url back from the dead - removing mark for death");
- unmark_for_death($contact);
+ logger("$url back from the dead - removing mark for death");
+ Contact::unmarkForArchival($contact);
}
if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
}
if ($final_dfrn_id != $orig_id) {
- logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
+ logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
// did not decode properly - cannot trust this site
return;
}
}
if ($xml) {
- logger('poller: received xml : ' . $xml, LOGGER_DATA);
+ logger('received xml : ' . $xml, LOGGER_DATA);
if (!strstr($xml, '<')) {
- logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
+ logger('post_handshake: response from ' . $url . ' did not contain XML.');
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
dba::update('contact', $fields, array('id' => $contact['id']));
logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
if (strlen($hub) && $hub_update && (($contact['rel'] != CONTACT_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED)) {
- logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
+ logger('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
$hubs = explode(',', $hub);
if (count($hubs)) {
foreach ($hubs as $h) {