Merge pull request #9217 from annando/fix-empty-preview

Fixes empty feed preview data
This commit is contained in:
Hypolite Petovan 2020-09-17 10:19:20 -04:00 committed by GitHub
commit 380cd902d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -533,6 +533,9 @@ class Feed
$replace = true; $replace = true;
} }
$saved_body = $item["body"];
$saved_title = $item["title"];
if ($replace) { if ($replace) {
$item["body"] = trim($item["title"]); $item["body"] = trim($item["title"]);
} }
@ -549,9 +552,24 @@ class Feed
} }
} }
$data = PageInfo::queryUrl($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_denylist"] ?? '');
// Take the data that was provided by the feed if the query is empty
if (($data['type'] == 'link') && empty($data['title']) && empty($data['text'])) {
$data['title'] = $saved_title;
$item["body"] = $saved_body;
}
$data_text = strip_tags(trim($data['text'] ?? ''));
$item_body = strip_tags(trim($item['body'] ?? ''));
if (($data_text == $item_body) || strstr($item_body, $data_text)) {
$data['text'] = '';
}
// We always strip the title since it will be added in the page information // We always strip the title since it will be added in the page information
$item["title"] = ""; $item["title"] = "";
$item["body"] = $item["body"] . "\n" . PageInfo::getFooterFromUrl($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_denylist"] ?? ''); $item["body"] = $item["body"] . "\n" . PageInfo::getFooterFromData($data, false);
$taglist = $contact["fetch_further_information"] == 2 ? PageInfo::getTagsFromUrl($item["plink"], $preview, $contact["ffi_keyword_denylist"] ?? '') : []; $taglist = $contact["fetch_further_information"] == 2 ? PageInfo::getTagsFromUrl($item["plink"], $preview, $contact["ffi_keyword_denylist"] ?? '') : [];
$item["object-type"] = Activity\ObjectType::BOOKMARK; $item["object-type"] = Activity\ObjectType::BOOKMARK;
unset($item["attach"]); unset($item["attach"]);