use Friendica\Util\Proxy;
use Friendica\Util\Strings;
use Friendica\Util\XML;
+use GuzzleHttp\Exception\TransferException;
/**
* This class contain functions to import feeds (RSS/RDF/Atom)
$orig_plink = $item["plink"];
- $item["plink"] = DI::httpClient()->finalUrl($item["plink"]);
+ try {
+ $item["plink"] = DI::httpClient()->finalUrl($item["plink"]);
+ } catch (TransferException $exception) {
+ Logger::notice('Item URL couldn\'t get expanded', ['url' => $item["plink"], 'exception' => $exception]);
+ }
$item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
XML::addElement($doc, $root, "id", DI::baseUrl() . "/profile/" . $owner["nick"]);
XML::addElement($doc, $root, "title", $title);
XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], DI::config()->get('config', 'sitename')));
- XML::addElement($doc, $root, "logo", Contact::getAvatarUrlForId($owner['id'], Proxy::SIZE_SMALL, $owner['updated']));
+ XML::addElement($doc, $root, "logo", User::getAvatarUrlForId($owner['uid'], Proxy::SIZE_SMALL));
XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
$author = self::addAuthor($doc, $owner);
if ($item['gravity'] != GRAVITY_PARENT) {
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
- $thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
+ $thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);
if (DBA::isResult($thrparent)) {
- $mentioned[$thrparent["author-link"]] = $thrparent["author-link"];
- $mentioned[$thrparent["owner-link"]] = $thrparent["owner-link"];
- $parent_plink = $thrparent["plink"];
+ $mentioned[$thrparent['author-link']] = $thrparent['author-link'];
+ $mentioned[$thrparent['owner-link']] = $thrparent['owner-link'];
+ $parent_plink = $thrparent['plink'];
+ } elseif (DBA::isResult($parent)) {
+ $mentioned[$parent['author-link']] = $parent['author-link'];
+ $mentioned[$parent['owner-link']] = $parent['owner-link'];
+ $parent_plink = DI::baseUrl() . '/display/' . $parent['guid'];
} else {
- $mentioned[$parent["author-link"]] = $parent["author-link"];
- $mentioned[$parent["owner-link"]] = $parent["owner-link"];
- $parent_plink = DI::baseUrl()."/display/".$parent["guid"];
+ DI::logger()->notice('Missing parent and thr-parent for child item', ['item' => $item]);
}
- $attributes = [
- "ref" => $item['thr-parent'],
- "href" => $parent_plink];
- XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
+ if (isset($parent_plink)) {
+ $attributes = [
+ 'ref' => $item['thr-parent'],
+ 'href' => $parent_plink];
+ XML::addElement($doc, $entry, 'thr:in-reply-to', '', $attributes);
- $attributes = [
- "rel" => "related",
- "href" => $parent_plink];
- XML::addElement($doc, $entry, "link", "", $attributes);
+ $attributes = [
+ 'rel' => 'related',
+ 'href' => $parent_plink];
+ XML::addElement($doc, $entry, 'link', '', $attributes);
+ }
}
// uri-id isn't present for follow entry pseudo-items
foreach ($tags as $tag) {
if ($tag['type'] == Tag::HASHTAG) {
- XML::addElement($doc, $entry, "category", "", ["term" => $tag['name']]);
+ XML::addElement($doc, $entry, 'category', '', ['term' => $tag['name']]);
}
}