]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Transmitter.php
Replaced all preg calls in the calls with the new function
[friendica.git] / src / Protocol / ActivityPub / Transmitter.php
index a9f5ed20a1976bab6ae936c52d6da951c2023603..5bb03a8517138f752194171a9aecf487cbd3adf2 100644 (file)
@@ -1401,23 +1401,12 @@ class Transmitter
         */
        public static function getAnnounceArray($item)
        {
-               if (!preg_match("/(.*?)\[share(.*?)\]\s?.*?\s?\[\/share\]\s?/ism", $item['body'], $matches)) {
+               $reshared = Item::getShareArray($item);
+               if (empty($reshared['guid'])) {
                        return [];
                }
 
-               $attributes = $matches[2];
-               $comment = $matches[1];
-
-               preg_match("/guid='(.*?)'/ism", $attributes, $matches);
-               if (empty($matches[1])) {
-                       preg_match('/guid="(.*?)"/ism', $attributes, $matches);
-               }
-
-               if (empty($matches[1])) {
-                       return [];
-               }
-
-               $reshared_item = Item::selectFirst([], ['guid' => $matches[1]]);
+               $reshared_item = Item::selectFirst([], ['guid' => $reshared['guid']]);
                if (!DBA::isResult($reshared_item)) {
                        return [];
                }
@@ -1431,7 +1420,7 @@ class Transmitter
                        return [];
                }
 
-               return ['object' => $reshared_item, 'actor' => $profile, 'comment' => trim($comment)];
+               return ['object' => $reshared_item, 'actor' => $profile, 'comment' => $reshared['comment']];
        }
 
        /**