]> git.mxchange.org Git - friendica.git/commitdiff
API: use `diaspora::is_reshare()`
authorfabrixxm <fabrix.xm@gmail.com>
Fri, 15 Jul 2016 10:22:35 +0000 (12:22 +0200)
committerfabrixxm <fabrix.xm@gmail.com>
Fri, 15 Jul 2016 10:22:35 +0000 (12:22 +0200)
include/api.php

index 5a3e92bb884d1d234d7c0213de0d3eb5d7d419d2..832240f716340b26bed12d96a74477c2e52ba2ab 100644 (file)
        function api_share_as_retweet(&$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 false;
-
-               // Does it end with a share?
-               if (strlen($body) > (strrpos($body, "[/share]") + 8))
+               if (diaspora::is_reshare($body, false)===false) {
                        return false;
+               }
 
                $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
                // Skip if there is no shared message in there
+               // we already checked this in diaspora::is_reshare()
+               // but better one more than one less...
                if ($body == $attributes)
                        return false;
 
-               // NOTE: we could check te guid="" attribute and then  try to load original post
-               //            from database given the guid: we can see the original post via web under
-               //                      /display/<guid>, but all the logic to fetch an item from db based on guid
-               //                      looks like is in display_init() and would need a big refractor to be usable here.
-               //                      so, we build the original item starting from the reshare.
 
+               // build the fake reshared item
                $reshared_item = $item;
 
                $author = "";