]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/OnePoll.php
Restructure (P)Config to follow new paradigm
[friendica.git] / src / Worker / OnePoll.php
index 7a674c87d0d8c6b41e62a42eb0a84c3f588f8077..99d5054ca3b8727ed9077d3410abdeb1f749e62c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -29,6 +29,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
 use Friendica\Model\User;
+use Friendica\Network\HTTPClientOptions;
 use Friendica\Protocol\Activity;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Protocol\Email;
@@ -81,7 +82,7 @@ class OnePoll
                                Logger::warning('No self contact for user', ['uid' => $importer_uid]);
 
                                // set the last-update so we don't keep polling
-                               DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
+                               Contact::update(['last-update' => $updated], ['id' => $contact['id']]);
                                return;
                        }
 
@@ -121,16 +122,16 @@ class OnePoll
        {
                if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL, Protocol::OSTATUS])) {
                        // Update the user's contact
-                       DBA::update('contact', $fields, ['id' => $contact['id']]);
+                       Contact::update($fields, ['id' => $contact['id']]);
 
                        // Update the public contact
-                       DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
+                       Contact::update($fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
 
                        // Update the rest of the contacts that aren't polled
-                       DBA::update('contact', $fields, ['rel' => Contact::FOLLOWER, 'nurl' => $contact['nurl']]);
+                       Contact::update($fields, ['rel' => Contact::FOLLOWER, 'nurl' => $contact['nurl']]);
                } else {
                        // Update all contacts
-                       DBA::update('contact', $fields, ['nurl' => $contact['nurl']]);
+                       Contact::update($fields, ['nurl' => $contact['nurl']]);
                }
        }
 
@@ -152,7 +153,7 @@ class OnePoll
                }
 
                $cookiejar = tempnam(get_temppath(), 'cookiejar-onepoll-');
-               $curlResult = DI::httpRequest()->get($contact['poll'], ['cookiejar' => $cookiejar]);
+               $curlResult = DI::httpClient()->get($contact['poll'], [HTTPClientOptions::COOKIEJAR => $cookiejar]);
                unlink($cookiejar);
 
                if ($curlResult->isTimeout()) {
@@ -245,7 +246,7 @@ class OnePoll
                                        $datarray['network'] = Protocol::MAIL;
                                        // $meta = Email::messageMeta($mbox, $msg_uid);
 
-                                       $datarray['uri'] = Email::msgid2iri(trim($meta->message_id, '<>'));
+                                       $datarray['thr-parent'] = $datarray['uri'] = Email::msgid2iri(trim($meta->message_id, '<>'));
 
                                        // Have we seen it before?
                                        $fields = ['deleted', 'id'];
@@ -455,10 +456,10 @@ class OnePoll
                Logger::info('Hub subscription start', ['mode' => $hubmode, 'name' => $contact['name'], 'hub' => $url, 'endpoint' => $push_url, 'verifier' => $verify_token]);
 
                if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
-                       DBA::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
+                       Contact::update(['hub-verify' => $verify_token], ['id' => $contact['id']]);
                }
 
-               $postResult = DI::httpRequest()->post($url, $params);
+               $postResult = DI::httpClient()->post($url, $params);
 
                Logger::info('Hub subscription done', ['result' => $postResult->getReturnCode()]);