]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #6890 from annando/ap-summary
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Sat, 16 Mar 2019 11:43:30 +0000 (12:43 +0100)
committerGitHub <noreply@github.com>
Sat, 16 Mar 2019 11:43:30 +0000 (12:43 +0100)
We now send a summary via AP

src/Protocol/ActivityPub/Transmitter.php
src/Protocol/Feed.php

index d85f67a7ccf126638517ac684a604bf207e4f1a7..79263f8ac06a705b5e1748530b9e5b0dc35fceb3 100644 (file)
@@ -20,6 +20,7 @@ use Friendica\Model\Term;
 use Friendica\Model\User;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Content\Text\BBCode;
+use Friendica\Content\Text\Plaintext;
 use Friendica\Util\JsonLD;
 use Friendica\Util\LDSignature;
 use Friendica\Model\Profile;
@@ -1020,7 +1021,7 @@ class Transmitter
                        return $data;
                }
 
-               $data['summary'] = null; // Ignore by now
+               $data['summary'] = BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB);
 
                if ($item['uri'] != $item['thr-parent']) {
                        $data['inReplyTo'] = $item['thr-parent'];
@@ -1054,6 +1055,8 @@ class Transmitter
 
                if ($type == 'Note') {
                        $body = self::removePictures($body);
+               } elseif (($type == 'Article') && empty($data['summary'])) {
+                       $data['summary'] = Plaintext::shorten(self::removePictures($body), 1000);
                }
 
                if ($type == 'Event') {
index 3981a8860cbf4c3f949885634bf9b703015c01a0..0cf1db7cb799dcafe5789157953c3767f4fe265e 100644 (file)
@@ -356,11 +356,20 @@ class Feed {
                        if (empty($body)) {
                                $body = trim(XML::getFirstNodeValue($xpath, 'content:encoded/text()', $entry));
                        }
-                       if (empty($body)) {
-                               $body = trim(XML::getFirstNodeValue($xpath, 'description/text()', $entry));
+
+                       $summary = trim(XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry));
+
+                       if (empty($summary)) {
+                               $summary = trim(XML::getFirstNodeValue($xpath, 'description/text()', $entry));
                        }
+
                        if (empty($body)) {
-                               $body = trim(XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry));
+                               $body = $summary;
+                               $summary = '';
+                       }
+
+                       if ($body == $summary) {
+                               $summary = '';
                        }
 
                        // remove the content of the title if it is identically to the body
@@ -411,6 +420,10 @@ class Feed {
                                $item["object-type"] = ACTIVITY_OBJ_BOOKMARK;
                                unset($item["attach"]);
                        } else {
+                               if (!empty($summary)) {
+                                       $item["body"] = '[abstract]' . HTML::toBBCode($summary, $basepath) . "[/abstract]\n" . $item["body"];
+                               }
+
                                if ($contact["fetch_further_information"] == 3) {
                                        if (!empty($tags)) {
                                                $item["tag"] = $tags;