]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/OStatus.php
Merge pull request #8690 from annando/no-activity
[friendica.git] / src / Protocol / OStatus.php
index 8ab14c07816eae6db6626a624a251dee9fa38127..4cb27956bac2575ad77d2ba1a2e3586a3d554e5e 100644 (file)
@@ -655,17 +655,8 @@ class OStatus
                        foreach ($categories as $category) {
                                foreach ($category->attributes as $attributes) {
                                        if ($attributes->name == 'term') {
-                                               $term = $attributes->textContent;
-                                               if (!empty($item['tag'])) {
-                                                       $item['tag'] .= ',';
-                                               } else {
-                                                       $item['tag'] = '';
-                                               }
-
-                                               $item['tag'] .= '#[url=' . DI::baseUrl() . '/search?tag=' . $term . ']' . $term . '[/url]';
-
                                                // Store the hashtag
-                                               Tag::store($item['uri-id'], Tag::HASHTAG, $term);
+                                               Tag::store($item['uri-id'], Tag::HASHTAG, $attributes->textContent);
                                        }
                                }
                        }
@@ -1010,7 +1001,7 @@ class OStatus
 
                // Even more worse workaround for GNU Social ;-)
                if ($xml == '') {
-                       $related_guess = OStatus::convertHref($related_uri);
+                       $related_guess = self::convertHref($related_uri);
                        $curlResult = Network::curl(str_replace('/notice/', '/api/statuses/show/', $related_guess).'.atom');
 
                        if ($curlResult->isSuccess()) {
@@ -1184,7 +1175,7 @@ class OStatus
         *
         * @return string URL in the format http(s)://....
         */
-       public static function convertHref($href)
+       private static function convertHref($href)
        {
                $elements = explode(":", $href);
 
@@ -1465,7 +1456,7 @@ class OStatus
                XML::addElement($doc, $author, "name", $owner["nick"]);
                XML::addElement($doc, $author, "email", $owner["addr"]);
                if ($show_profile) {
-                       XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, 7));
+                       XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, BBCode::OSTATUS));
                }
 
                $attributes = ["rel" => "alternate", "type" => "text/html", "href" => $owner["url"]];
@@ -1492,7 +1483,7 @@ class OStatus
                XML::addElement($doc, $author, "poco:preferredUsername", $owner["nick"]);
                XML::addElement($doc, $author, "poco:displayName", $owner["name"]);
                if ($show_profile) {
-                       XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, 7));
+                       XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, BBCode::OSTATUS));
 
                        if (trim($owner["location"]) != "") {
                                $element = $doc->createElement("poco:address");
@@ -1904,7 +1895,7 @@ class OStatus
 
                if (!$toplevel) {
                        if (!empty($item['title'])) {
-                               $title = BBCode::convert($item['title'], false, 7);
+                               $title = BBCode::convert($item['title'], false, BBCode::OSTATUS);
                        } else {
                                $title = sprintf("New note by %s", $owner["nick"]);
                        }
@@ -1993,7 +1984,7 @@ class OStatus
                        $body = "[b]".$item['title']."[/b]\n\n".$body;
                }
 
-               $body = BBCode::convert($body, false, 7);
+               $body = BBCode::convert($body, false, BBCode::OSTATUS);
 
                XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);
 
@@ -2081,11 +2072,10 @@ class OStatus
                        XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
                }
 
-               $tags = Tag::getByURIId($item['uri-id']);
-               if (count($tags)) {
-                       foreach ($tags as $tag) {
-                               $mentioned[$tag['url']] = $tag['url'];
-                       }
+               // uri-id isn't present for follow entry pseudo-items
+               $tags = Tag::getByURIId($item['uri-id'] ?? 0);
+               foreach ($tags as $tag) {
+                       $mentioned[$tag['url']] = $tag['url'];
                }
 
                // Make sure that mentions are accepted (GNU Social has problems with mixing HTTP and HTTPS)
@@ -2134,11 +2124,9 @@ class OStatus
                        XML::addElement($doc, $entry, "mastodon:scope", "public");
                }
 
-               if (count($tags)) {
-                       foreach ($tags as $tag) {
-                               if ($tag['type'] == Tag::HASHTAG) {
-                                       XML::addElement($doc, $entry, "category", "", ["term" => $tag['name']]);
-                               }
+               foreach ($tags as $tag) {
+                       if ($tag['type'] == Tag::HASHTAG) {
+                               XML::addElement($doc, $entry, "category", "", ["term" => $tag['name']]);
                        }
                }