]> git.mxchange.org Git - friendica.git/commitdiff
"nsfw" at "content warning" content doesn't fit together
authorMichael <heluecht@pirati.ca>
Tue, 13 Mar 2018 22:39:08 +0000 (22:39 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 13 Mar 2018 22:39:08 +0000 (22:39 +0000)
src/Protocol/OStatus.php

index aa1079407af6a6896c55d6d50735fcf8b2284ff5..c7c264f5a3876d0abc1c45b7932af5fe00a9257c 100644 (file)
@@ -604,21 +604,6 @@ class OStatus
                        $item["coord"] = $georsspoint->item(0)->nodeValue;
                }
 
-               $categories = $xpath->query('atom:category', $entry);
-               if ($categories) {
-                       foreach ($categories as $category) {
-                               foreach ($category->attributes as $attributes) {
-                                       if ($attributes->name == "term") {
-                                               $term = $attributes->textContent;
-                                               if (strlen($item["tag"])) {
-                                                       $item["tag"] .= ',';
-                                               }
-                                               $item["tag"] .= "#[url=".System::baseUrl()."/search?tag=".$term."]".$term."[/url]";
-                                       }
-                               }
-                       }
-               }
-
                $self = '';
                $add_body = '';
 
@@ -658,10 +643,12 @@ class OStatus
                }
 
                // Mastodon Content Warning
+               $content_warning = false;
                if (($item["verb"] == ACTIVITY_POST) && $xpath->evaluate('boolean(atom:summary)', $entry)) {
                        $clear_text = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
                        if (!empty($clear_text)) {
                                $item["body"] = html2bbcode($clear_text) . '[spoiler]' . $item["body"] . '[/spoiler]';
+                               $content_warning = true;
                        }
                }
 
@@ -686,6 +673,25 @@ class OStatus
                        $item["parent-uri"] = $item["uri"];
                }
 
+               $categories = $xpath->query('atom:category', $entry);
+               if ($categories) {
+                       foreach ($categories as $category) {
+                               foreach ($category->attributes as $attributes) {
+                                       if ($attributes->name == "term") {
+                                               $term = $attributes->textContent;
+                                               // don't add nsfw with content warning
+                                               // Background: "nsfw" is set automatically by Mastodon and superfluous
+                                               if (!$content_warning || ($term != 'nsfw')) {
+                                                       if (strlen($item["tag"])) {
+                                                               $item["tag"] .= ',';
+                                                       }
+                                                       $item["tag"] .= "#[url=".System::baseUrl()."/search?tag=".$term."]".$term."[/url]";
+                                               }
+                                       }
+                               }
+                       }
+               }
+
                if (($item['author-link'] != '') && !empty($item['protocol'])) {
                        $item = Conversation::insert($item);
                }