X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fonepoll.php;h=90d018524d13aae89bf653dc3cdfb81b9a3f04f2;hb=9eca83e29c6f292ab4d95d90789df06bf8d04d34;hp=7b93a9a2f0d0a63e7ee422f0919b2b08c28597cf;hpb=2dafc9eac18756fbe52760d1d84ee8e8187165d1;p=friendica.git diff --git a/include/onepoll.php b/include/onepoll.php index 7b93a9a2f0..90d018524d 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -1,6 +1,7 @@ $contact['failure_update'])) { + $r = q("SELECT count(*) as total from glink + where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY", + intval($contact['id']) + ); + if (count($r)) + if (!$r[0]['total']) + poco_load($contact['id'],$importer_uid,0,$contact['poco']); + } + + // To-Do: + // - Check why we don't poll the Diaspora feed at the moment (some guid problem in the items?) + // - 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"]); + $updated = datetime_convert(); + if ($last_updated) { + q("UPDATE `contact` SET `last-item` = '%s', `last-update` = '%s', `success_update` = '%s' WHERE `id` = %d", + dbesc($last_updated), + dbesc($updated), + dbesc($updated), + intval($contact['id']) + ); + } else { + q("UPDATE `contact` SET `last-update` = '%s', `failure_update` = '%s' WHERE `id` = %d", + dbesc($updated), + dbesc($updated), + intval($contact['id']) + ); + } + } + return; + } + $xml = false; $t = $contact['last-update']; @@ -129,6 +164,10 @@ function onepoll_run(&$argv, &$argc){ : datetime_convert('UTC','UTC',$contact['last-update'], ATOM_TIME) ); + // Update the contact entry + if(($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) + update_contact($contact["id"]); + if($contact['network'] === NETWORK_DFRN) { @@ -168,7 +207,8 @@ function onepoll_run(&$argv, &$argc){ mark_for_death($contact); // set the last-update so we don't keep polling - $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d", + $r = q("UPDATE `contact` SET `last-update` = '%s', `failure_update` = '%s' WHERE `id` = %d", + dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact['id']) ); @@ -181,7 +221,8 @@ function onepoll_run(&$argv, &$argc){ mark_for_death($contact); - $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d", + $r = q("UPDATE `contact` SET `last-update` = '%s', `failure_update` = '%s' WHERE `id` = %d", + dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact['id']) ); @@ -198,7 +239,8 @@ function onepoll_run(&$argv, &$argc){ // set the last-update so we don't keep polling - $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d", + $r = q("UPDATE `contact` SET `last-update` = '%s', `failure_update` = '%s' WHERE `id` = %d", + dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact['id']) ); @@ -243,8 +285,8 @@ function onepoll_run(&$argv, &$argc){ $final_dfrn_id = substr($final_dfrn_id,2); if($final_dfrn_id != $orig_id) { - logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id); - // did not decode properly - cannot trust this site + logger('poller: ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id); + // did not decode properly - cannot trust this site return; } @@ -255,7 +297,7 @@ function onepoll_run(&$argv, &$argc){ $xml = post_url($contact['poll'],$postvars); } - elseif(($contact['network'] === NETWORK_OSTATUS) + elseif(($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_FEED) ) { @@ -265,7 +307,8 @@ function onepoll_run(&$argv, &$argc){ $stat_writeable = ((($contact['notify']) && ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['rel'] == CONTACT_IS_FRIEND)) ? 1 : 0); - if($contact['network'] === NETWORK_OSTATUS && get_pconfig($importer_uid,'system','ostatus_autofriend')) + // Contacts from OStatus are always writable + if($contact['network'] === NETWORK_OSTATUS) $stat_writeable = 1; if($stat_writeable != $contact['writable']) { @@ -544,14 +587,14 @@ function onepoll_run(&$argv, &$argc){ logger('poller: received xml : ' . $xml, LOGGER_DATA); if(! strstr($xml,'<')) { logger('poller: post_handshake: response from ' . $url . ' did not contain XML.'); - $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d", + $r = q("UPDATE `contact` SET `last-update` = '%s', `failure_update` = '%s' WHERE `id` = %d", + dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact['id']) ); return; } - consume_feed($xml,$importer,$contact,$hub,1,1); @@ -578,29 +621,38 @@ function onepoll_run(&$argv, &$argc){ } } } - } - $updated = datetime_convert(); + $updated = datetime_convert(); - $r = q("UPDATE `contact` SET `last-update` = '%s', `success_update` = '%s' WHERE `id` = %d", - dbesc($updated), - dbesc($updated), - intval($contact['id']) - ); + $r = q("UPDATE `contact` SET `last-update` = '%s', `success_update` = '%s' WHERE `id` = %d", + dbesc($updated), + dbesc($updated), + intval($contact['id']) + ); + q("UPDATE `gcontact` SET `last_contact` = '%s' WHERE `nurl` = '%s'", + dbesc($updated), + dbesc($contact['nurl']) + ); - // load current friends if possible. + } elseif (in_array($contact["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED))) { + $updated = datetime_convert(); - if($contact['poco']) { - $r = q("SELECT count(*) as total from glink - where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY", + $r = q("UPDATE `contact` SET `last-update` = '%s', `failure_update` = '%s' WHERE `id` = %d", + dbesc($updated), + dbesc($updated), + intval($contact['id']) + ); + + q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'", + dbesc($updated), + dbesc($contact['nurl']) + ); + } else { + $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d", + dbesc($updated), intval($contact['id']) ); - } - if(count($r)) { - if(! $r[0]['total']) { - poco_load($contact['id'],$importer_uid,0,$contact['poco']); - } } return;