]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
doc/themes.md,FAQ-admin: point to live friendica-themes.com mirror
[friendica.git] / src / Model / Item.php
index aff9dfed0b40fe9739274f8249e7071c2f9062a6..d040c876de6df1ab4a1ee614102173943bfbc66a 100644 (file)
@@ -1773,7 +1773,10 @@ class Item
        }
 
        /**
-        * Creates an unique guid out of a given uri
+        * Creates an unique guid out of a given uri.
+        * This function is used for messages outside the fediverse (Connector posts, feeds, Mails, ...)
+        * Posts that are created on this system are using System::createUUID.
+        * Received ActivityPub posts are using Processor::getGUIDByURL.
         *
         * @param string $uri uri of an item entry
         * @param string $host hostname for the GUID prefix
@@ -3188,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'],
@@ -3196,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'),
                        ];