]> git.mxchange.org Git - friendica.git/commitdiff
Add spoiler tags for Mastodon Content Warning
authorHypolite Petovan <mrpetovan@gmail.com>
Mon, 10 Apr 2017 04:08:14 +0000 (00:08 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Mon, 10 Apr 2017 04:08:14 +0000 (00:08 -0400)
include/ostatus.php

index 9b78495093e1b802767b0075b54ac3608d15e0ea..73fcb47572bd7849895b35ba04674bc2dd2be0cd 100644 (file)
@@ -353,14 +353,21 @@ 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;
 
-                       if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) OR ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
+                       if ($item["object-type"] == ACTIVITY_OBJ_NOTE && $xpath->evaluate('boolean(atom:summary)', $entry)) {
+                               // Mastodon Content Warning
+                               $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["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;
                        $item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;