]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/OnePoll.php
Merge pull request #11955 from annando/issue-11953
[friendica.git] / src / Worker / OnePoll.php
index 79369681ca693ced2eee80f31a92b8e973dad287..83a7a5f15c228c0bd6fc016cc5fd553c77192094 100644 (file)
@@ -27,6 +27,7 @@ use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
+use Friendica\Model\Conversation;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
 use Friendica\Model\User;
@@ -41,11 +42,11 @@ use Friendica\Util\Strings;
 
 class OnePoll
 {
-       public static function execute($contact_id = 0, $command = '')
+       public static function execute(int $contact_id = 0, string $command = '')
        {
                Logger::notice('Start polling/probing contact', ['id' => $contact_id]);
 
-               $force = ($command == "force");
+               $force = ($command == 'force');
 
                if (empty($contact_id)) {
                        Logger::notice('no contact provided');
@@ -118,6 +119,7 @@ class OnePoll
         *
         * @param array $contact The personal contact entry
         * @param array $fields  The fields that are updated
+        * @return void
         * @throws \Exception
         */
        private static function updateContact(array $contact, array $fields)
@@ -155,7 +157,7 @@ class OnePoll
                }
 
                $cookiejar = tempnam(System::getTempPath(), 'cookiejar-onepoll-');
-               $curlResult = DI::httpClient()->get($contact['poll'], [HttpClientOptions::COOKIEJAR => $cookiejar, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::FEED_XML]);
+               $curlResult = DI::httpClient()->get($contact['poll'], HttpClientAccept::FEED_XML, [HttpClientOptions::COOKIEJAR => $cookiejar]);
                unlink($cookiejar);
 
                if ($curlResult->isTimeout()) {
@@ -246,6 +248,9 @@ class OnePoll
                                        $datarray['verb'] = Activity::POST;
                                        $datarray['object-type'] = Activity\ObjectType::NOTE;
                                        $datarray['network'] = Protocol::MAIL;
+                                       $datarray['protocol'] = Conversation::PARCEL_IMAP;
+                                       $datarray['direction'] = Conversation::PULL;
+                               
                                        // $meta = Email::messageMeta($mbox, $msg_uid);
 
                                        $datarray['thr-parent'] = $datarray['uri'] = Email::msgid2iri(trim($meta->message_id, '<>'));
@@ -389,7 +394,7 @@ class OnePoll
 
                                        $datarray = Email::getMessage($mbox, $msg_uid, $reply, $datarray);
                                        if (empty($datarray['body'])) {
-                                               Logger::notice("Mail: can't fetch msg ".$msg_uid." for ".$mailconf['user']);
+                                               Logger::warning('Cannot fetch mail', ['msg-id' => $msg_uid, 'uid' => $mailconf['user']]);
                                                continue;
                                        }