]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/OnePoll.php
Superfluous todo removed
[friendica.git] / src / Worker / OnePoll.php
index b2c49c9f1dfa5af17227ea438c2770e1588285e3..65f2277b73a3dd3825db48aac039209ab8d502f4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -30,6 +30,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
 use Friendica\Model\User;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
 use Friendica\Network\HTTPClient\Client\HttpClientOptions;
 use Friendica\Protocol\Activity;
 use Friendica\Protocol\ActivityPub;
@@ -40,11 +41,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');
@@ -117,6 +118,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)
@@ -154,7 +156,7 @@ class OnePoll
                }
 
                $cookiejar = tempnam(System::getTempPath(), 'cookiejar-onepoll-');
-               $curlResult = DI::httpClient()->get($contact['poll'], [HttpClientOptions::COOKIEJAR => $cookiejar]);
+               $curlResult = DI::httpClient()->get($contact['poll'], HttpClientAccept::FEED_XML, [HttpClientOptions::COOKIEJAR => $cookiejar]);
                unlink($cookiejar);
 
                if ($curlResult->isTimeout()) {
@@ -173,7 +175,7 @@ class OnePoll
                        return false;
                }
 
-               Logger::notice('Consume feed of contact', ['id' => $contact['id'], 'url' => $contact['poll']]);
+               Logger::notice('Consume feed of contact', ['id' => $contact['id'], 'url' => $contact['poll'], 'Content-Type' => $curlResult->getHeader('Content-Type')]);
 
                return !empty(Feed::import($xml, $importer, $contact));
        }