Merge remote-tracking branch 'upstream/develop' into post-delivery-data

This commit is contained in:
Michael 2020-05-04 14:40:52 +00:00
commit 16d486dd24
15 changed files with 62 additions and 544 deletions

View file

@ -387,7 +387,7 @@ class Processor
if (empty($activity['directmessage']) && ($item['thr-parent'] != $item['uri']) && ($item['gravity'] == GRAVITY_COMMENT)) {
$item_private = !in_array(0, $activity['item_receiver']);
$parent = Item::selectFirst(['id', 'private', 'author-link', 'alias'], ['uri' => $item['thr-parent']]);
$parent = Item::selectFirst(['id', 'uri-id', 'private', 'author-link', 'alias'], ['uri' => $item['thr-parent']]);
if (!DBA::isResult($parent)) {
Logger::warning('Unknown parent item.', ['uri' => $item['thr-parent']]);
return false;

View file

@ -1080,21 +1080,15 @@ class DFRN
$entry->appendChild($actarg);
}
$tags = Item::getFeedTags($item);
$tags = Tag::getByURIId($item['uri-id']);
/// @TODO Combine this with similar below if() block?
if (count($tags)) {
foreach ($tags as $t) {
if (($type != 'html') || ($t[0] != "@")) {
XML::addElement($doc, $entry, "category", "", ["scheme" => "X-DFRN:".$t[0].":".$t[1], "term" => $t[2]]);
foreach ($tags as $tag) {
if (($type != 'html') || ($tag['type'] == Tag::HASHTAG)) {
XML::addElement($doc, $entry, "category", "", ["scheme" => "X-DFRN:" . Tag::TAG_CHARACTER[$tag['type']] . ":" . $tag['url'], "term" => $tag['name']]);
}
}
}
if (count($tags)) {
foreach ($tags as $t) {
if ($t[0] == "@") {
$mentioned[$t[1]] = $t[1];
if ($tag['type'] != Tag::HASHTAG) {
$mentioned[$tag['url']] = $tag['url'];
}
}
}
@ -2238,11 +2232,6 @@ class DFRN
// extract tag, if not duplicate, add to parent item
if ($xo->content) {
Tag::store($item_tag['uri-id'], Tag::HASHTAG, $xo->content);
if (!stristr($item_tag["tag"], trim($xo->content))) {
$tag = $item_tag["tag"] . (strlen($item_tag["tag"]) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]';
Item::update(['tag' => $tag], ['id' => $item_tag["id"]]);
}
}
}
}
@ -2440,17 +2429,7 @@ class DFRN
if (($term != "") && ($scheme != "")) {
$parts = explode(":", $scheme);
if ((count($parts) >= 4) && (array_shift($parts) == "X-DFRN")) {
$termhash = array_shift($parts);
$termurl = implode(":", $parts);
if (!empty($item["tag"])) {
$item["tag"] .= ",";
} else {
$item["tag"] = "";
}
$item["tag"] .= $termhash . "[url=" . $termurl . "]" . $term . "[/url]";
Tag::store($item['uri-id'], Tag::IMPLICIT_MENTION, $term, $termurl);
}
}

View file

@ -2582,7 +2582,7 @@ class Diaspora
}
// Do we already have this item?
$fields = ['body', 'title', 'attach', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
$fields = ['body', 'title', 'attach', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar'];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]];
$item = Item::selectFirst($fields, $condition);
@ -2626,7 +2626,7 @@ class Diaspora
}
if ($stored) {
$fields = ['body', 'title', 'attach', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
$fields = ['body', 'title', 'attach', 'app', 'created', 'object-type', 'uri', 'guid',
'author-name', 'author-link', 'author-avatar'];
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => [Item::PUBLIC, Item::UNLISTED]];
$item = Item::selectFirst($fields, $condition);
@ -2772,7 +2772,6 @@ class Diaspora
Tag::storeFromBody($datarray['uri-id'], $datarray["body"]);
$datarray["tag"] = $original_item["tag"];
$datarray["attach"] = $original_item["attach"];
$datarray["app"] = $original_item["app"];

View file

@ -385,18 +385,10 @@ class Feed {
$item["attach"] .= '[attach]href="' . $href . '" length="' . $length . '" type="' . $type . '"[/attach]';
}
$tags = '';
$taglist = [];
$categories = $xpath->query("category", $entry);
foreach ($categories AS $category) {
$hashtag = $category->nodeValue;
if ($tags != '') {
$tags .= ', ';
}
$taglink = "#[url=" . DI::baseUrl() . "/search?tag=" . $hashtag . "]" . $hashtag . "[/url]";
$tags .= $taglink;
$taglist[] = $hashtag;
$taglist[] = $category->nodeValue;
}
$body = trim(XML::getFirstNodeValue($xpath, 'atom:content/text()', $entry));
@ -477,7 +469,6 @@ class Feed {
// We always strip the title since it will be added in the page information
$item["title"] = "";
$item["body"] = $item["body"] . add_page_info($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
$item["tag"] = add_page_keywords($item["plink"], $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
$taglist = get_page_keywords($item["plink"], $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
$item["object-type"] = Activity\ObjectType::BOOKMARK;
unset($item["attach"]);
@ -487,14 +478,10 @@ class Feed {
}
if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] == 3)) {
if (!empty($tags)) {
$item["tag"] = $tags;
} else {
// @todo $preview is never set in this case, is it intended? - @MrPetovan 2018-02-13
$item["tag"] = add_page_keywords($item["plink"], $preview, true, $contact["ffi_keyword_blacklist"]);
if (empty($taglist)) {
$taglist = get_page_keywords($item["plink"], $preview, true, $contact["ffi_keyword_blacklist"]);
}
$item["body"] .= "\n" . $item['tag'];
$item["body"] .= "\n" . self::tagToString($taglist);
} else {
$taglist = [];
}
@ -540,6 +527,27 @@ class Feed {
return ["header" => $author, "items" => $items];
}
/**
* Convert a tag array to a tag string
*
* @param array $tags
* @return string tag string
*/
private static function tagToString(array $tags)
{
$tagstr = '';
foreach ($tags as $tag) {
if ($tagstr != "") {
$tagstr .= ", ";
}
$tagstr .= "#[url=" . DI::baseUrl() . "/search?tag=" . urlencode($tag) . "]" . $tag . "[/url]";
}
return $tagstr;
}
private static function titleIsBody($title, $body)
{
$title = strip_tags($title);

View file

@ -2081,13 +2081,10 @@ class OStatus
XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
}
$tags = item::getFeedTags($item);
$tags = Tag::getByURIId($item['uri-id']);
if (count($tags)) {
foreach ($tags as $t) {
if ($t[0] == "@") {
$mentioned[$t[1]] = $t[1];
}
foreach ($tags as $tag) {
$mentioned[$tag['url']] = $tag['url'];
}
}
@ -2138,9 +2135,9 @@ class OStatus
}
if (count($tags)) {
foreach ($tags as $t) {
if ($t[0] != "@") {
XML::addElement($doc, $entry, "category", "", ["term" => $t[2]]);
foreach ($tags as $tag) {
if ($tag['type'] == Tag::HASHTAG) {
XML::addElement($doc, $entry, "category", "", ["term" => $tag['name']]);
}
}
}