]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
Merge branch 'bug/phpinfo-accessible-hotfix' into 2020.09-rc
[friendica.git] / src / Protocol / OStatus.php
index 9a52476b569b47ee0d010acaa84e6f05367235db..0635be87d1c9a83191d80ac0bed7d349b06ed577 100644 (file)
@@ -34,7 +34,6 @@ use Friendica\DI;
 use Friendica\Model\APContact;
 use Friendica\Model\Contact;
 use Friendica\Model\Conversation;
-use Friendica\Model\GContact;
 use Friendica\Model\Item;
 use Friendica\Model\ItemURI;
 use Friendica\Model\Tag;
@@ -42,7 +41,6 @@ use Friendica\Model\User;
 use Friendica\Network\Probe;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Images;
-use Friendica\Util\Network;
 use Friendica\Util\Proxy as ProxyUtils;
 use Friendica\Util\Strings;
 use Friendica\Util\XML;
@@ -217,11 +215,11 @@ class OStatus
 
                        if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) {
                                Logger::log("Update profile picture for contact ".$contact["id"], Logger::DEBUG);
-                               Contact::updateAvatar($author["author-avatar"], $importer["uid"], $contact["id"]);
+                               Contact::updateAvatar($contact["id"], $author["author-avatar"]);
                        }
 
                        // Ensure that we are having this contact (with uid=0)
-                       $cid = Contact::getIdForURL($aliaslink, 0, false);
+                       $cid = Contact::getIdForURL($aliaslink);
 
                        if ($cid) {
                                $fields = ['url', 'nurl', 'name', 'nick', 'alias', 'about', 'location'];
@@ -238,18 +236,9 @@ class OStatus
 
                                // Update the avatar
                                if (!empty($author["author-avatar"])) {
-                                       Contact::updateAvatar($author["author-avatar"], 0, $cid);
+                                       Contact::updateAvatar($cid, $author["author-avatar"]);
                                }
                        }
-
-                       $contact["generation"] = 2;
-                       $contact["hide"] = false; // OStatus contacts are never hidden
-                       if (!empty($author["author-avatar"])) {
-                               $contact["photo"] = $author["author-avatar"];
-                       }
-                       $gcid = GContact::update($contact);
-
-                       GContact::link($gcid, $contact["uid"], $contact["id"]);
                } elseif (empty($contact["network"]) || ($contact["network"] != Protocol::DFRN)) {
                        $contact = [];
                }
@@ -555,15 +544,8 @@ class OStatus
                                                } elseif ($item['contact-id'] < 0) {
                                                        Logger::log("Item with uri ".$item["uri"]." is from a blocked contact.", Logger::DEBUG);
                                                } else {
-                                                       // We are having duplicated entries. Hopefully this solves it.
-                                                       if (DI::lock()->acquire('ostatus_process_item_insert')) {
-                                                               $ret = Item::insert($item);
-                                                               DI::lock()->release('ostatus_process_item_insert');
-                                                               Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"].' stored. Return value: '.$ret);
-                                                       } else {
-                                                               $ret = Item::insert($item);
-                                                               Logger::log("We couldn't lock - but tried to store the item anyway. Return value is ".$ret);
-                                                       }
+                                                       $ret = Item::insert($item);
+                                                       Logger::log("Item with uri ".$item["uri"]." for user ".$importer["uid"].' stored. Return value: '.$ret);
                                                }
                                        }
                                }
@@ -756,7 +738,7 @@ class OStatus
 
                self::$conv_list[$conversation] = true;
 
-               $curlResult = Network::curl($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
+               $curlResult = DI::httpRequest()->get($conversation, false, ['accept_content' => 'application/atom+xml, text/html']);
 
                if (!$curlResult->isSuccess()) {
                        return;
@@ -785,7 +767,7 @@ class OStatus
                                        }
                                }
                                if ($file != '') {
-                                       $conversation_atom = Network::curl($attribute['href']);
+                                       $conversation_atom = DI::httpRequest()->get($attribute['href']);
 
                                        if ($conversation_atom->isSuccess()) {
                                                $xml = $conversation_atom->getBody();
@@ -902,7 +884,7 @@ class OStatus
                        return;
                }
 
-               $curlResult = Network::curl($self);
+               $curlResult = DI::httpRequest()->get($self);
 
                if (!$curlResult->isSuccess()) {
                        return;
@@ -949,7 +931,7 @@ class OStatus
                }
 
                $stored = false;
-               $curlResult = Network::curl($related, false, ['accept_content' => 'application/atom+xml, text/html']);
+               $curlResult = DI::httpRequest()->get($related, false, ['accept_content' => 'application/atom+xml, text/html']);
 
                if (!$curlResult->isSuccess()) {
                        return;
@@ -980,7 +962,7 @@ class OStatus
                                        }
                                }
                                if ($atom_file != '') {
-                                       $curlResult = Network::curl($atom_file);
+                                       $curlResult = DI::httpRequest()->get($atom_file);
 
                                        if ($curlResult->isSuccess()) {
                                                Logger::log('Fetched XML for URI ' . $related_uri, Logger::DEBUG);
@@ -992,7 +974,7 @@ class OStatus
 
                // Workaround for older GNU Social servers
                if (($xml == '') && strstr($related, '/notice/')) {
-                       $curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related).'.atom');
+                       $curlResult = DI::httpRequest()->get(str_replace('/notice/', '/api/statuses/show/', $related) . '.atom');
 
                        if ($curlResult->isSuccess()) {
                                Logger::log('GNU Social workaround to fetch XML for URI ' . $related_uri, Logger::DEBUG);
@@ -1003,7 +985,7 @@ class OStatus
                // Even more worse workaround for GNU Social ;-)
                if ($xml == '') {
                        $related_guess = self::convertHref($related_uri);
-                       $curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom');
+                       $curlResult = DI::httpRequest()->get(str_replace('/notice/', '/api/statuses/show/', $related_guess) . '.atom');
 
                        if ($curlResult->isSuccess()) {
                                Logger::log('GNU Social workaround 2 to fetch XML for URI ' . $related_uri, Logger::DEBUG);
@@ -2028,7 +2010,7 @@ class OStatus
                $mentioned = $newmentions;
 
                foreach ($mentioned as $mention) {
-                       $contact = Contact::getByURL($mention, ['contact-type']);
+                       $contact = Contact::getByURL($mention, false, ['contact-type']);
                        if (!empty($contact) && ($contact['contact-type'] == Contact::TYPE_COMMUNITY)) {
                                XML::addElement($doc, $entry, "link", "",
                                        [
@@ -2140,7 +2122,7 @@ class OStatus
                }
 
                $check_date = DateTimeFormat::utc($last_update);
-               $authorid = Contact::getIdForURL($owner["url"], 0, false);
+               $authorid = Contact::getIdForURL($owner["url"]);
 
                $condition = ["`uid` = ? AND `received` > ? AND NOT `deleted`
                        AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?)",
@@ -2229,14 +2211,13 @@ class OStatus
         * Checks if the given contact url does support OStatus
         *
         * @param string  $url    profile url
-        * @param boolean $update Update the profile
         * @return boolean
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function isSupportedByContactUrl($url, $update = false)
+       public static function isSupportedByContactUrl($url)
        {
-               $probe = Probe::uri($url, Protocol::OSTATUS, 0, !$update);
+               $probe = Probe::uri($url, Protocol::OSTATUS);
                return $probe['network'] == Protocol::OSTATUS;
        }
 }