]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
Merge pull request #8934 from annando/fix-fatal
[friendica.git] / src / Protocol / OStatus.php
index d496389c58c1401cd8454b81233d537114bad1d8..1cf2894eb548742058e39435a0085579b0027ace 100644 (file)
@@ -42,7 +42,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,7 +216,7 @@ 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)
@@ -238,7 +237,7 @@ class OStatus
 
                                // Update the avatar
                                if (!empty($author["author-avatar"])) {
-                                       Contact::updateAvatar($author["author-avatar"], 0, $cid);
+                                       Contact::updateAvatar($cid, $author["author-avatar"]);
                                }
                        }
 
@@ -698,7 +697,7 @@ class OStatus
 
                // Only add additional data when there is no picture in the post
                if (!strstr($item["body"], '[/img]')) {
-                       $item["body"] = PageInfo::appendToBody($item["body"]);
+                       $item["body"] = PageInfo::searchAndAppendToBody($item["body"]);
                }
 
                Tag::storeFromBody($item['uri-id'], $item['body']);
@@ -756,7 +755,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 +784,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 +901,7 @@ class OStatus
                        return;
                }
 
-               $curlResult = Network::curl($self);
+               $curlResult = DI::httpRequest()->get($self);
 
                if (!$curlResult->isSuccess()) {
                        return;
@@ -949,7 +948,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 +979,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 +991,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 +1002,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);
@@ -1332,7 +1331,7 @@ class OStatus
                $attributes = ["href" => DI::baseUrl() . $selfUri, "rel" => "self", "type" => "application/atom+xml"];
                XML::addElement($doc, $root, "link", "", $attributes);
 
-               if ($owner['account-type'] == Contact::TYPE_COMMUNITY) {
+               if ($owner['contact-type'] == Contact::TYPE_COMMUNITY) {
                        $condition = ['uid' => $owner['uid'], 'self' => false, 'pending' => false,
                                        'archive' => false, 'hidden' => false, 'blocked' => false];
                        $members = DBA::count('contact', $condition);
@@ -1445,7 +1444,7 @@ class OStatus
                $profile = DBA::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid']]);
                $author = $doc->createElement("author");
                XML::addElement($doc, $author, "id", $owner["url"]);
-               if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
+               if ($owner['contact-type'] == Contact::TYPE_COMMUNITY) {
                        XML::addElement($doc, $author, "activity:object-type", Activity\ObjectType::GROUP);
                } else {
                        XML::addElement($doc, $author, "activity:object-type", Activity\ObjectType::PERSON);
@@ -1876,7 +1875,7 @@ class OStatus
                if (!$toplevel) {
                        $entry = $doc->createElement("entry");
 
-                       if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
+                       if ($owner['contact-type'] == Contact::TYPE_COMMUNITY) {
                                $contact = Contact::getByURL($item['author-link']) ?: $owner;
                                $author = self::addAuthor($doc, $contact, false);
                                $entry->appendChild($author);
@@ -2046,7 +2045,7 @@ class OStatus
                        }
                }
 
-               if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
+               if ($owner['contact-type'] == Contact::TYPE_COMMUNITY) {
                        XML::addElement($doc, $entry, "link", "", [
                                "rel" => "mentioned",
                                "ostatus:object-type" => "http://activitystrea.ms/schema/1.0/group",
@@ -2151,7 +2150,7 @@ class OStatus
                        $condition[] = Activity\ObjectType::COMMENT;
                }
 
-               if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
+               if ($owner['contact-type'] != Contact::TYPE_COMMUNITY) {
                        $condition[0] .= " AND `contact-id` = ? AND `author-id` = ?";
                        $condition[] = $owner["id"];
                        $condition[] = $authorid;