X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FFeed.php;h=8cb08f65df3788a93cf2d528d3837ff360c4dbed;hb=f1d6e7ebb47cc2ba37c5a7982fc4f54678e5d7ea;hp=a9e50d532ca9cdf749b668ef1dffc24bcf75440b;hpb=24f8ee8e676abf4dd16916fd417562aca7bcbb9f;p=friendica.git diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index a9e50d532c..8cb08f65df 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -401,7 +401,16 @@ class Feed } if (!empty($href)) { - $attachments[] = ['type' => Post\Media::DOCUMENT, 'url' => $href, 'mimetype' => $type, 'size' => $length]; + $attachment = ['type' => Post\Media::UNKNOWN, 'url' => $href, 'mimetype' => $type, 'size' => $length]; + + $attachment = Post\Media::fetchAdditionalData($attachment); + + // By now we separate the visible media types (audio, video, image) from the rest + // In the future we should try to avoid the DOCUMENT type and only use the real one - but not in the RC phase. + if (!in_array($attachment['type'], [Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO])) { + $attachment['type'] = Post\Media::DOCUMENT; + } + $attachments[] = $attachment; } } @@ -525,6 +534,29 @@ class Feed $taglist = $contact["fetch_further_information"] == 2 ? PageInfo::getTagsFromUrl($item["plink"], $preview, $contact["ffi_keyword_denylist"] ?? '') : []; $item["object-type"] = Activity\ObjectType::BOOKMARK; $attachments = []; + + foreach (['audio', 'video'] as $elementname) { + if (!empty($data[$elementname])) { + foreach ($data[$elementname] as $element) { + if (!empty($element['src'])) { + $src = $element['src']; + } elseif (!empty($element['content'])) { + $src = $element['content']; + } else { + continue; + } + + $attachments[] = [ + 'type' => ($elementname == 'audio') ? Post\Media::AUDIO : Post\Media::VIDEO, + 'url' => $src, + 'preview' => $element['image'] ?? null, + 'mimetype' => $element['contenttype'] ?? null, + 'name' => $element['name'] ?? null, + 'description' => $element['description'] ?? null, + ]; + } + } + } } } else { if (!empty($summary)) { @@ -541,7 +573,7 @@ class Feed } // Add the link to the original feed entry if not present in feed - if (($item['plink'] != '') && !strstr($item["body"], $item['plink'])) { + if (($item['plink'] != '') && !strstr($item["body"], $item['plink']) && !in_array($item['plink'], array_column($attachments, 'url'))) { $item["body"] .= "[hr][url]" . $item['plink'] . "[/url]"; } }