X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FOnePoll.php;h=5fc65b211a1d4f4414d896c64ef1d64c5f737f97;hb=3a1fef43b237a4fcb75d7880aa81808a66c56f2d;hp=17986121085c19e423e6f1f18c1883219daf14b3;hpb=b50f91b3e176e7501efc541391ee362a04b0cc4e;p=friendica.git diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 1798612108..5fc65b211a 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -32,9 +32,7 @@ use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityPub; use Friendica\Protocol\Email; use Friendica\Protocol\Feed; -use Friendica\Protocol\PortableContact; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -62,13 +60,13 @@ class OnePoll return; } - if (($contact['network'] != Protocol::MAIL) || $force) { - Contact::updateFromProbe($contact_id, '', $force); + if (($contact['network'] != Protocol::MAIL) && $force) { + Contact::updateFromProbe($contact_id); } // Special treatment for wrongly detected local contacts if (!$force && ($contact['network'] != Protocol::DFRN) && Contact::isLocalById($contact_id)) { - Contact::updateFromProbe($contact_id, Protocol::DFRN, true); + Contact::updateFromProbe($contact_id, Protocol::DFRN); $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]); } @@ -96,13 +94,6 @@ class OnePoll $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]); } - // load current friends if possible. - if (!empty($contact['poco']) && ($contact['success_update'] > $contact['failure_update'])) { - if (!DBA::exists('glink', ["`cid` = ? AND updated > UTC_TIMESTAMP() - INTERVAL 1 DAY", $contact['id']])) { - PortableContact::loadWorker($contact['id'], $importer_uid, 0, $contact['poco']); - } - } - // Don't poll if polling is deactivated (But we poll feeds and mails anyway) if (!in_array($protocol, [Protocol::FEED, Protocol::MAIL]) && DI::config()->get('system', 'disable_polling')) { Logger::log('Polling is disabled'); @@ -112,6 +103,15 @@ class OnePoll return; } + // Don't poll local contacts + if (User::getIdForURL($contact['url'])) { + Logger::info('Local contacts are not polled', ['id' => $contact['id']]); + + // set the last-update so we don't keep polling + DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]); + return; + } + // We don't poll AP contacts by now if ($protocol === Protocol::ACTIVITYPUB) { Logger::log("Don't poll AP contact"); @@ -291,7 +291,7 @@ class OnePoll . '&type=data&last_update=' . $last_update . '&perm=' . $perm; - $curlResult = Network::curl($url); + $curlResult = DI::httpRequest()->get($url); if (!$curlResult->isSuccess() && ($curlResult->getErrorNumber() == CURLE_OPERATION_TIMEDOUT)) { // set the last-update so we don't keep polling @@ -405,7 +405,7 @@ class OnePoll $postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION; $postvars['perm'] = 'rw'; - return Network::post($contact['poll'], $postvars)->getBody(); + return DI::httpRequest()->post($contact['poll'], $postvars)->getBody(); } /** @@ -444,7 +444,7 @@ class OnePoll } $cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-'); - $curlResult = Network::curl($contact['poll'], false, ['cookiejar' => $cookiejar]); + $curlResult = DI::httpRequest()->get($contact['poll'], false, ['cookiejar' => $cookiejar]); unlink($cookiejar); if ($curlResult->isTimeout()) { @@ -708,6 +708,9 @@ class OnePoll Logger::log("Mail: no mails for ".$mailconf['user']); } + self::updateContact($contact, ['failed' => false, 'last-update' => $updated, 'success_update' => $updated]); + Contact::unmarkForArchival($contact); + Logger::log("Mail: closing connection for ".$mailconf['user']); imap_close($mbox); } @@ -756,7 +759,7 @@ class OnePoll DBA::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]); } - $postResult = Network::post($url, $params); + $postResult = DI::httpRequest()->post($url, $params); Logger::log('subscribe_to_hub: returns: ' . $postResult->getReturnCode(), Logger::DEBUG);