<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
$author["author-link"] = XML::getFirstNodeValue($xpath, '/rss/channel/link/text()');
$author["author-name"] = XML::getFirstNodeValue($xpath, '/rss/channel/title/text()');
- $author["author-avatar"] = XML::getFirstNodeValue($xpath, '/rss/channel/image/url/text()');
if (empty($author["author-name"])) {
$author["author-name"] = XML::getFirstNodeValue($xpath, '/rss/channel/copyright/text()');
$author["author-name"] = XML::getFirstNodeValue($xpath, '/rss/channel/description/text()');
}
+ $author["author-avatar"] = XML::getFirstNodeValue($xpath, '/rss/channel/image/url/text()');
+
+ if (empty($author["author-avatar"])) {
+ $avatar = XML::getFirstAttributes($xpath, "/rss/channel/itunes:image");
+ if (is_object($avatar)) {
+ foreach ($avatar as $attribute) {
+ if ($attribute->name == "href") {
+ $author["author-avatar"] = $attribute->textContent;
+ }
+ }
+ }
+ }
+
+ $author["author-about"] = HTML::toBBCode(XML::getFirstNodeValue($xpath, '/rss/channel/description/text()'), $basepath);
+
+ if (empty($author["author-about"])) {
+ $author["author-about"] = XML::getFirstNodeValue($xpath, '/rss/channel/itunes:summary/text()');
+ }
+
$author["edited"] = $author["created"] = XML::getFirstNodeValue($xpath, '/rss/channel/pubDate/text()');
$author["app"] = XML::getFirstNodeValue($xpath, '/rss/channel/generator/text()');
$item["plink"] = XML::getFirstNodeValue($xpath, 'rss:link/text()', $entry);
}
+ // Add the base path if missing
+ $item["plink"] = Network::addBasePath($item["plink"], $basepath);
+
$item["uri"] = XML::getFirstNodeValue($xpath, 'atom:id/text()', $entry);
- if (empty($item["uri"])) {
- $item["uri"] = XML::getFirstNodeValue($xpath, 'guid/text()', $entry);
+ $guid = XML::getFirstNodeValue($xpath, 'guid/text()', $entry);
+ if (!empty($guid)) {
+ $item["uri"] = $guid;
+
+ // Don't use the GUID value directly but instead use it as a basis for the GUID
+ $item["guid"] = Item::guidFromUri($guid, parse_url($guid, PHP_URL_HOST) ?? parse_url($item["plink"], PHP_URL_HOST));
}
if (empty($item["uri"])) {
$item["uri"] = $item["plink"];
}
- // Add the base path if missing
- $item["uri"] = Network::addBasePath($item["uri"], $basepath);
- $item["plink"] = Network::addBasePath($item["plink"], $basepath);
-
$orig_plink = $item["plink"];
try {
if (empty($item["title"])) {
$item["title"] = XML::getFirstNodeValue($xpath, 'title/text()', $entry);
}
+
if (empty($item["title"])) {
$item["title"] = XML::getFirstNodeValue($xpath, 'rss:title/text()', $entry);
}
+ if (empty($item["title"])) {
+ $item["title"] = XML::getFirstNodeValue($xpath, 'itunes:title/text()', $entry);
+ }
+
$item["title"] = html_entity_decode($item["title"], ENT_QUOTES, 'UTF-8');
$published = XML::getFirstNodeValue($xpath, 'atom:published/text()', $entry);
}
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;
}
}
}
if ($dryRun) {
+ $item['attachments'] = $attachments;
$items[] = $item;
break;
} elseif (!Item::isValid($item)) {
$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)) {
}
// 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]";
}
}
$cachekey = "feed:feed:" . $owner_nick . ":" . $filter . ":" . $last_update;
+ // Display events in the users's timezone
+ if (strlen($owner['timezone'])) {
+ DI::app()->setTimeZone($owner['timezone']);
+ }
+
$previous_created = $last_update;
// Don't cache when the last item was posted less then 15 minutes ago (Cache duration)