[twitter] Use original URL for link display #788

Merged
MrPetovan merged 1 commit from bug/4708-twitter-show-original-url-share into 2019.01-rc 2019-01-12 10:18:18 +01:00

View file

@ -1221,9 +1221,11 @@ function twitter_expand_entities(App $a, $body, $item, $picture)
continue; continue;
} }
$expanded_url = Network::finalUrl($url->expanded_url); $expanded_url = $url->expanded_url;
$oembed_data = OEmbed::fetchURL($expanded_url); $final_url = Network::finalUrl($url->expanded_url);
$oembed_data = OEmbed::fetchURL($final_url);
if (empty($oembed_data) || empty($oembed_data->type)) { if (empty($oembed_data) || empty($oembed_data->type)) {
continue; continue;
@ -1249,7 +1251,7 @@ function twitter_expand_entities(App $a, $body, $item, $picture)
} elseif ($oembed_data->type != 'link') { } elseif ($oembed_data->type != 'link') {
$body = str_replace($url->url, '[url=' . $expanded_url . ']' . $url->display_url . '[/url]', $body); $body = str_replace($url->url, '[url=' . $expanded_url . ']' . $url->display_url . '[/url]', $body);
} else { } else {
$img_str = Network::fetchUrl($expanded_url, true, $redirects, 4); $img_str = Network::fetchUrl($final_url, true, $redirects, 4);
$tempfile = tempnam(get_temppath(), 'cache'); $tempfile = tempnam(get_temppath(), 'cache');
file_put_contents($tempfile, $img_str); file_put_contents($tempfile, $img_str);
@ -1265,7 +1267,7 @@ function twitter_expand_entities(App $a, $body, $item, $picture)
if (substr($mime, 0, 6) == 'image/') { if (substr($mime, 0, 6) == 'image/') {
$type = 'photo'; $type = 'photo';
$body = str_replace($url->url, '[img]' . $expanded_url . '[/img]', $body); $body = str_replace($url->url, '[img]' . $final_url . '[/img]', $body);
} else { } else {
$type = $oembed_data->type; $type = $oembed_data->type;
$footerurl = $expanded_url; $footerurl = $expanded_url;