]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
No blubb allowed
[friendica.git] / src / Model / Item.php
index a465e8c93c5f5fae8e6f5d13736e64d26aede265..7eb36d85e025f2aaae996af6db3a6d676cb08f96 100644 (file)
@@ -79,6 +79,8 @@ class Item
        const PR_DIRECT = 77;
        const PR_ACTIVITY = 78;
        const PR_DISTRIBUTE = 79;
+       const PR_PUSHED = 80;
+       const PR_LOCAL = 81;
 
        // system.accept_only_sharer setting values
        const COMPLETION_NONE    = 1;
@@ -908,6 +910,10 @@ class Item
                        $item['post-reason'] = self::PR_FOLLOWER;
                }
 
+               if ($item['origin'] && empty($item['post-reason'])) {
+                       $item['post-reason'] = self::PR_LOCAL;
+               }
+
                // Ensure that there is an avatar cache
                Contact::checkAvatarCache($item['author-id']);
                Contact::checkAvatarCache($item['owner-id']);
@@ -1385,7 +1391,7 @@ class Item
                $condition = ['id' => $itemid, 'uid' => 0,
                        'network' => array_merge(Protocol::FEDERATED ,['']),
                        'visible' => true, 'deleted' => false, 'private' => [self::PUBLIC, self::UNLISTED]];
-               $item = Post::selectFirst(self::ITEM_FIELDLIST, $condition);
+               $item = Post::selectFirst(array_merge(self::ITEM_FIELDLIST, ['protocol']), $condition);
                if (!DBA::isResult($item)) {
                        Logger::warning('Item not found', ['condition' => $condition]);
                        return;
@@ -1474,7 +1480,7 @@ class Item
                        return 0;
                }
 
-               $item = Post::selectFirst(self::ITEM_FIELDLIST, ['uri-id' => $uri_id, 'uid' => $source_uid]);
+               $item = Post::selectFirst(array_merge(self::ITEM_FIELDLIST, ['protocol']), ['uri-id' => $uri_id, 'uid' => $source_uid]);
                if (!DBA::isResult($item)) {
                        Logger::warning('Item could not be fetched', ['uri-id' => $uri_id, 'uid' => $source_uid]);
                        return 0;
@@ -1691,7 +1697,7 @@ class Item
                        return;
                }
 
-               $item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]);
+               $item = Post::selectFirst(array_merge(self::ITEM_FIELDLIST, ['protocol']), ['id' => $itemid]);
 
                if (DBA::isResult($item)) {
                        // Preparing public shadow (removing user specific data)
@@ -1727,7 +1733,7 @@ class Item
         */
        private static function addShadowPost(int $itemid)
        {
-               $item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]);
+               $item = Post::selectFirst(array_merge(self::ITEM_FIELDLIST, ['protocol']), ['id' => $itemid]);
                if (!DBA::isResult($item)) {
                        return;
                }
@@ -2945,9 +2951,13 @@ class Item
        {
                // Make sure that for example site parameters aren't used when testing if the link is contained in the body
                $urlparts = parse_url($url);
-               unset($urlparts['query']);
-               unset($urlparts['fragment']);
-               $url = Uri::fromParts($urlparts);
+               if (!empty($urlparts)) {
+                       unset($urlparts['query']);
+                       unset($urlparts['fragment']);
+                       $url = (string)Uri::fromParts($urlparts);
+               } else {
+                       return false;
+               }
 
                // Remove media links to only search in embedded content
                // @todo Check images for image link, audio for audio links, ...