]> git.mxchange.org Git - friendica.git/commitdiff
Summary has to be converted to HTML / Don't use summary when we have the source
authorMichael <heluecht@pirati.ca>
Sun, 17 Mar 2019 00:06:31 +0000 (00:06 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 17 Mar 2019 00:06:31 +0000 (00:06 +0000)
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Transmitter.php

index 1850c572a47817f9589e43d3ebb84c123f74cc46..ccc313840897191ffaa80146b955f7e6658a40f1 100644 (file)
@@ -138,22 +138,27 @@ class Processor
                $item['changed'] = DateTimeFormat::utcNow();
                $item['edited'] = $activity['updated'];
                $item['title'] = HTML::toBBCode($activity['name']);
-               $item['content-warning'] = HTML::toBBCode($activity['summary']);
 
-               $content = HTML::toBBCode($activity['content']);
-               $content = self::replaceEmojis($content, $activity['emojis']);
-               $content = self::convertMentions($content);
+               if (!empty($activity['source'])) {
+                       $content = $activity['source'];
+               } else {
+                       $item['content-warning'] = HTML::toBBCode($activity['summary']);
 
-               if (($item['thr-parent'] != $item['uri']) && ($item['gravity'] == GRAVITY_COMMENT)) {
-                       $parent = Item::selectFirst(['id', 'author-link', 'alias'], ['uri' => $item['thr-parent']]);
-                       if (!DBA::isResult($parent)) {
-                               Logger::warning('Unknown parent item.', ['uri' => $item['thr-parent']]);
-                               return;
-                       }
+                       $content = HTML::toBBCode($activity['content']);
+                       $content = self::replaceEmojis($content, $activity['emojis']);
+                       $content = self::convertMentions($content);
 
-                       $potential_implicit_mentions = self::getImplicitMentionList($parent);
-                       $content = self::removeImplicitMentionsFromBody($content, $potential_implicit_mentions);
-                       $activity['tags'] = self::convertImplicitMentionsInTags($activity['tags'], $potential_implicit_mentions);
+                       if (($item['thr-parent'] != $item['uri']) && ($item['gravity'] == GRAVITY_COMMENT)) {
+                               $parent = Item::selectFirst(['id', 'author-link', 'alias'], ['uri' => $item['thr-parent']]);
+                               if (!DBA::isResult($parent)) {
+                                       Logger::warning('Unknown parent item.', ['uri' => $item['thr-parent']]);
+                                       return;
+                               }
+
+                               $potential_implicit_mentions = self::getImplicitMentionList($parent);
+                               $content = self::removeImplicitMentionsFromBody($content, $potential_implicit_mentions);
+                               $activity['tags'] = self::convertImplicitMentionsInTags($activity['tags'], $potential_implicit_mentions);
+                       }
                }
 
                $item['body'] = $content;
@@ -339,6 +344,7 @@ class Processor
                $item = self::constructAttachList($activity['attachments'], $item);
 
                if (!empty($activity['source'])) {
+                       $item['content-warning'] = '';
                        $item['body'] = $activity['source'];
                }
 
index 79263f8ac06a705b5e1748530b9e5b0dc35fceb3..8f9687a804f35258031f0a03d2855fa1584d8632 100644 (file)
@@ -1021,7 +1021,7 @@ class Transmitter
                        return $data;
                }
 
-               $data['summary'] = BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB);
+               $data['summary'] = BBCode::convert(BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB), false, 7);
 
                if ($item['uri'] != $item['thr-parent']) {
                        $data['inReplyTo'] = $item['thr-parent'];
@@ -1056,7 +1056,7 @@ class Transmitter
                if ($type == 'Note') {
                        $body = self::removePictures($body);
                } elseif (($type == 'Article') && empty($data['summary'])) {
-                       $data['summary'] = Plaintext::shorten(self::removePictures($body), 1000);
+                       $data['summary'] = BBCode::convert(Plaintext::shorten(self::removePictures($body), 1000), false, 7);
                }
 
                if ($type == 'Event') {