]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/OEmbed.php
Contact follow and unfollow workd partially
[friendica.git] / src / Content / OEmbed.php
index 64ddc64f036a7e291008f9fa37777950e72885c4..dd6ac7caa23109834e2959bb0035a680a755c9ce 100644 (file)
@@ -19,9 +19,9 @@ use Friendica\Database\DBA;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\ParseUrl;
+use Friendica\Util\Proxy as ProxyUtils;
 
 require_once 'include/dba.php';
-require_once 'mod/proxy.php';
 
 /**
  * Handles all OEmbed content fetching and replacement
@@ -112,6 +112,7 @@ class OEmbed
                        }
 
                        $oembed->parseJSON($json_string);
+
                        if (!empty($oembed->type) && $oembed->type != 'error') {
                                DBA::insert('oembed', [
                                        'url' => normalise_link($embedurl),
@@ -119,9 +120,12 @@ class OEmbed
                                        'content' => $json_string,
                                        'created' => DateTimeFormat::utcNow()
                                ], true);
+                               $cache_ttl = CACHE_DAY;
+                       } else {
+                               $cache_ttl = CACHE_FIVE_MINUTES;
                        }
 
-                       Cache::set($cache_key, $json_string, CACHE_DAY);
+                       Cache::set($cache_key, $json_string, $cache_ttl);
                }
 
                if ($oembed->type == 'error') {
@@ -148,7 +152,7 @@ class OEmbed
                                $oembed->description = $data['text'];
                        }
 
-                       if (is_array($data['images'])) {
+                       if (!empty($data['images'])) {
                                $oembed->thumbnail_url = $data['images'][0]['src'];
                                $oembed->thumbnail_width = $data['images'][0]['width'];
                                $oembed->thumbnail_height = $data['images'][0]['height'];
@@ -187,13 +191,16 @@ class OEmbed
                                        $ret = $oembed->html;
                                }
                                break;
+
                        case "photo":
-                               $ret .= '<img width="' . $oembed->width . '" src="' . proxy_url($oembed->url) . '">';
+                               $ret .= '<img width="' . $oembed->width . '" src="' . ProxyUtils::proxifyUrl($oembed->url) . '">';
                                break;
+
                        case "link":
                                break;
+
                        case "rich":
-                               $ret .= proxy_parse_html($oembed->html);
+                               $ret .= ProxyUtils::proxifyHtml($oembed->html);
                                break;
                }