]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Diaspora.php
Replaced all preg calls in the calls with the new function
[friendica.git] / src / Protocol / Diaspora.php
index cf53d2fc26d6b42c7acdbee67047290c24d71c37..c52213972e1947063b38b581aea4709aa6abe876 100644 (file)
@@ -3391,69 +3391,37 @@ class Diaspora
        {
                $body = trim($body);
 
-               // Skip if it isn't a pure repeated messages
-               // Does it start with a share?
-               if ((strpos($body, "[share") > 0) && $complete) {
-                       return false;
-               }
-
-               // Does it end with a share?
-               if (strlen($body) > (strrpos($body, "[/share]") + 8)) {
+               $reshared = Item::getShareArray(['body' => $body]);
+               if (empty($reshared)) {
                        return false;
                }
 
-               $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
-               // Skip if there is no shared message in there
-               if ($body == $attributes) {
+               // Skip if it isn't a pure repeated messages
+               // Does it start with a share?
+               if (!empty($reshared['comment']) && $complete) {
                        return false;
                }
 
-               // If we don't do the complete check we quit here
-
-               $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];
-               }
-
-               if (($guid != "") && $complete) {
-                       $condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
+               if (!empty($reshared['guid']) && $complete) {
+                       $condition = ['guid' => $reshared['guid'], 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
                        $item = Item::selectFirst(['contact-id'], $condition);
                        if (DBA::isResult($item)) {
                                $ret = [];
                                $ret["root_handle"] = self::handleFromContact($item["contact-id"]);
-                               $ret["root_guid"] = $guid;
+                               $ret["root_guid"] = $reshared['guid'];
                                return $ret;
                        } elseif ($complete) {
                                // We are resharing something that isn't a DFRN or Diaspora post.
                                // So we have to return "false" on "$complete" to not trigger a reshare.
                                return false;
                        }
-               } elseif (($guid == "") && $complete) {
+               } elseif (empty($reshared['guid']) && $complete) {
                        return false;
                }
 
-               $ret["root_guid"] = $guid;
-
-               $profile = "";
-               preg_match("/profile='(.*?)'/ism", $attributes, $matches);
-               if (!empty($matches[1])) {
-                       $profile = $matches[1];
-               }
-
-               preg_match('/profile="(.*?)"/ism', $attributes, $matches);
-               if (!empty($matches[1])) {
-                       $profile = $matches[1];
-               }
-
                $ret = [];
 
-               if (!empty($profile) && ($cid = Contact::getIdForURL($profile))) {
+               if (!empty($reshared['profile']) && ($cid = Contact::getIdForURL($reshared['profile']))) {
                        $contact = DBA::selectFirst('contact', ['addr'], ['id' => $cid]);
                        if (!empty($contact['addr'])) {
                                $ret['root_handle'] = $contact['addr'];