]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #11452 from atjn/manifest-icons
[friendica.git] / src / Model / Item.php
index 5047af5986da9e6209eb4ea28305c36b50c26748..34f7e0d8b8959e61e80d4d99def20eb1461e5a23 100644 (file)
@@ -869,7 +869,7 @@ class Item
                $item["contact-id"] = self::contactId($item);
 
                if (!empty($item['direction']) && in_array($item['direction'], [Conversation::PUSH, Conversation::RELAY]) &&
-                       self::isTooOld($item)) {
+                       empty($item['origin']) &&self::isTooOld($item)) {
                        Logger::info('Item is too old', ['item' => $item]);
                        return 0;
                }
@@ -1751,7 +1751,7 @@ class Item
                // which point it will be automatically available through `getAvailableLanguages()` and this should be removed.
                $availableLanguages['fa'] = 'fa';
 
-               $ld = new Language($availableLanguages);
+               $ld = new Language(array_keys($availableLanguages));
                $languages = $ld->detect($naked_body)->limit(0, 3)->close();
                if (is_array($languages)) {
                        return json_encode($languages);
@@ -3191,6 +3191,12 @@ class Item
         */
        public static function getPlink($item)
        {
+               if (!empty($item['plink']) && Network::isValidHttpUrl($item['plink'])) {
+                       $plink = $item['plink'];
+               } elseif (!empty($item['uri']) && Network::isValidHttpUrl($item['uri']) && !Network::isLocalLink($item['uri'])) {
+                       $plink = $item['uri'];
+               }
+
                if (local_user()) {
                        $ret = [
                                'href' => "display/" . $item['guid'],
@@ -3199,14 +3205,14 @@ class Item
                                'orig_title' => DI::l10n()->t('View on separate page'),
                        ];
 
-                       if (!empty($item['plink'])) {
-                               $ret['href'] = DI::baseUrl()->remove($item['plink']);
+                       if (!empty($plink)) {
+                               $ret['href'] = DI::baseUrl()->remove($plink);
                                $ret['title'] = DI::l10n()->t('Link to source');
                        }
-               } elseif (!empty($item['plink']) && ($item['private'] != self::PRIVATE)) {
+               } elseif (!empty($plink) && ($item['private'] != self::PRIVATE)) {
                        $ret = [
-                               'href' => $item['plink'],
-                               'orig' => $item['plink'],
+                               'href' => $plink,
+                               'orig' => $plink,
                                'title' => DI::l10n()->t('Link to source'),
                                'orig_title' => DI::l10n()->t('Link to source'),
                        ];