Merge pull request #6890 from annando/ap-summary

We now send a summary via AP
This commit is contained in:
Tobias Diekershoff 2019-03-16 12:43:30 +01:00 committed by GitHub
commit 23ed4b9f62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View file

@ -20,6 +20,7 @@ use Friendica\Model\Term;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Plaintext;
use Friendica\Util\JsonLD; use Friendica\Util\JsonLD;
use Friendica\Util\LDSignature; use Friendica\Util\LDSignature;
use Friendica\Model\Profile; use Friendica\Model\Profile;
@ -1020,7 +1021,7 @@ class Transmitter
return $data; return $data;
} }
$data['summary'] = null; // Ignore by now $data['summary'] = BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB);
if ($item['uri'] != $item['thr-parent']) { if ($item['uri'] != $item['thr-parent']) {
$data['inReplyTo'] = $item['thr-parent']; $data['inReplyTo'] = $item['thr-parent'];
@ -1054,6 +1055,8 @@ class Transmitter
if ($type == 'Note') { if ($type == 'Note') {
$body = self::removePictures($body); $body = self::removePictures($body);
} elseif (($type == 'Article') && empty($data['summary'])) {
$data['summary'] = Plaintext::shorten(self::removePictures($body), 1000);
} }
if ($type == 'Event') { if ($type == 'Event') {

View file

@ -356,11 +356,20 @@ class Feed {
if (empty($body)) { if (empty($body)) {
$body = trim(XML::getFirstNodeValue($xpath, 'content:encoded/text()', $entry)); $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)) { 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 // 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; $item["object-type"] = ACTIVITY_OBJ_BOOKMARK;
unset($item["attach"]); unset($item["attach"]);
} else { } else {
if (!empty($summary)) {
$item["body"] = '[abstract]' . HTML::toBBCode($summary, $basepath) . "[/abstract]\n" . $item["body"];
}
if ($contact["fetch_further_information"] == 3) { if ($contact["fetch_further_information"] == 3) {
if (!empty($tags)) { if (!empty($tags)) {
$item["tag"] = $tags; $item["tag"] = $tags;