]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
"FetchPoCo" added
[friendica.git] / src / Protocol / OStatus.php
index 9a41920ae8378f12fafbb19e05a49fe3d49b9673..a63b12731dd3556cb56dcf3650b3cd76d7aca244 100644 (file)
@@ -25,8 +25,9 @@ use Friendica\Model\Item;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
 use Friendica\Object\Image;
-use Friendica\Protocol\Activity\ActivityNamespace;
+use Friendica\Protocol\ActivityNamespace;
 use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Images;
 use Friendica\Util\Network;
 use Friendica\Util\Proxy as ProxyUtils;
 use Friendica\Util\Strings;
@@ -1198,37 +1199,12 @@ class OStatus
         */
        private static function getResharedGuid(array $item)
        {
-               $body = trim($item["body"]);
-
-               // Skip if it isn't a pure repeated messages
-               // Does it start with a share?
-               if (strpos($body, "[share") > 0) {
-                       return "";
-               }
-
-               // Does it end with a share?
-               if (strlen($body) > (strrpos($body, "[/share]") + 8)) {
-                       return "";
-               }
-
-               $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
-               // Skip if there is no shared message in there
-               if ($body == $attributes) {
-                       return false;
-               }
-
-               $guid = "";
-               preg_match("/guid='(.*?)'/ism", $attributes, $matches);
-               if (!empty($matches[1])) {
-                       $guid = $matches[1];
-               }
-
-               preg_match('/guid="(.*?)"/ism', $attributes, $matches);
-               if (!empty($matches[1])) {
-                       $guid = $matches[1];
+               $reshared = Item::getShareArray($item);
+               if (empty($reshared['guid']) || !empty($reshared['comment'])) {
+                       return '';
                }
 
-               return $guid;
+               return $reshared['guid'];
        }
 
        /**
@@ -1389,7 +1365,7 @@ class OStatus
                switch ($siteinfo["type"]) {
                        case 'photo':
                                if (!empty($siteinfo["image"])) {
-                                       $imgdata = Image::getInfoFromURL($siteinfo["image"]);
+                                       $imgdata = Images::getInfoFromURLCached($siteinfo["image"]);
                                        if ($imgdata) {
                                                $attributes = ["rel" => "enclosure",
                                                                "href" => $siteinfo["image"],
@@ -1413,7 +1389,7 @@ class OStatus
                }
 
                if (!Config::get('system', 'ostatus_not_attach_preview') && ($siteinfo["type"] != "photo") && isset($siteinfo["image"])) {
-                       $imgdata = Image::getInfoFromURL($siteinfo["image"]);
+                       $imgdata = Images::getInfoFromURLCached($siteinfo["image"]);
                        if ($imgdata) {
                                $attributes = ["rel" => "enclosure",
                                                "href" => $siteinfo["image"],
@@ -1760,7 +1736,7 @@ class OStatus
 
                $entry = self::entryHeader($doc, $owner, $item, $toplevel);
 
-               $verb = Activity\ActivityNamespace::ACTIVITY_SCHEMA . "favorite";
+               $verb = ActivityNamespace::ACTIVITY_SCHEMA . "favorite";
                self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false);
 
                $parent = Item::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]);