]> git.mxchange.org Git - friendica.git/commitdiff
Rewrote code according to @annando feedback
authorHypolite Petovan <mrpetovan@gmail.com>
Tue, 11 Apr 2017 01:11:28 +0000 (21:11 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Tue, 11 Apr 2017 01:11:28 +0000 (21:11 -0400)
- Normalize boolean operators

include/ostatus.php

index 9c1246c85c3f48a8f065f06e4fc3a783aa361000..b8db50cd1d3a97592b857b057085a6d284aca1a3 100644 (file)
@@ -353,26 +353,25 @@ class ostatus {
                                continue;
                        }
 
+                       $item["body"] = add_page_info_to_body(html2bbcode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue));
                        $item["object-type"] = $xpath->query('activity:object-type/text()', $entry)->item(0)->nodeValue;
                        $item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
 
-                       if ($item["verb"] == ACTIVITY_POST && $xpath->evaluate('boolean(atom:summary)', $entry)) {
-                               // Mastodon Content Warning
+                       // Mastodon Content Warning
+                       if ($item["verb"] == ACTIVITY_POST AND $xpath->evaluate('boolean(atom:summary)', $entry)) {
                                $clear_text = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
-                               $hidden_text = $xpath->query('atom:content/text()', $entry)->item(0)->nodeValue;
 
-                               $item["body"] = add_page_info_to_body(html2bbcode($clear_text) . '[spoiler]' . html2bbcode($hidden_text) . '[/spoiler]');
-                       } elseif (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) OR ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
+                               $item["body"] = html2bbcode($clear_text) . '[spoiler]' . $item["body"] . '[/spoiler]';
+                       }
+
+                       if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) OR ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
                                $item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
                                $item["body"] = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
                        } elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION) {
                                $item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
-                       } else {
-                               $item["body"] = add_page_info_to_body(html2bbcode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue));
                        }
                        $item["object"] = $xml;
 
-
                        /// @TODO
                        /// Delete a message
                        if ($item["verb"] == "qvitter-delete-notice") {
@@ -2060,7 +2059,7 @@ class ostatus {
 
                $mentioned = array();
 
-               if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
+               if (($item['parent'] != $item['id']) OR ($item['parent-uri'] !== $item['uri']) OR (($item['thr-parent'] !== '') AND ($item['thr-parent'] !== $item['uri']))) {
                        $parent = q("SELECT `guid`, `author-link`, `owner-link` FROM `item` WHERE `id` = %d", intval($item["parent"]));
                        $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);