]> git.mxchange.org Git - friendica.git/commitdiff
Code is simplyfied
authorMichael <heluecht@pirati.ca>
Sat, 29 Oct 2022 22:55:39 +0000 (22:55 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 29 Oct 2022 22:55:39 +0000 (22:55 +0000)
src/Content/Item.php
src/Model/Item.php

index f226867ec8cb211b1d9e64ef84d72ae7c8a001da..3d6443fe3fc2c625d890754717bb1fd0ee2ca845 100644 (file)
@@ -748,8 +748,7 @@ class Item
                        return $body;
                }
 
-               $link = $post['plink'] ?: $post['uri'];
-               $body .= "\n♲ " . $link;
+               $body .= "\n♲ " . ($post['plink'] ?: $post['uri']);
 
                return $body;
        }
index 5f2f51834509613c6236a3477bcd18233ad953ba..f95b22e27beb87e11c208d2fda6cdf06ea991a1e 100644 (file)
@@ -3662,38 +3662,39 @@ class Item
                        $shared_item = Post::selectFirst(['uri-id'], ['guid' => $shared['guid'], 'uid' => [0, $uid]]);
                        if (!empty($shared_item['uri-id'])) {
                                Logger::debug('Found post by guid', ['guid' => $shared['guid'], 'uid' => $uid]);
+                               return $shared_item['uri-id'];
                        }
                }
 
-               if (empty($shared_item['uri-id']) && !empty($shared['message_id'])) {
+               if (!empty($shared['message_id'])) {
                        $shared_item = Post::selectFirst(['uri-id'], ['uri' => $shared['message_id'], 'uid' => [0, $uid]]);
                        if (!empty($shared_item['uri-id'])) {
                                Logger::debug('Found post by message_id', ['message_id' => $shared['message_id'], 'uid' => $uid]);
+                               return $shared_item['uri-id'];
                        }
                }
 
-               if (empty($shared_item['uri-id']) && !empty($shared['link'])) {
+               if (!empty($shared['link'])) {
                        $shared_item = Post::selectFirst(['uri-id'], ['plink' => $shared['link'], 'uid' => [0, $uid]]);
                        if (!empty($shared_item['uri-id'])) {
                                Logger::debug('Found post by link', ['link' => $shared['link'], 'uid' => $uid]);
+                               return $shared_item['uri-id'];
                        }
                }
 
-               if (empty($shared_item['uri-id'])) {
-                       $url = $shared['message_id'] ?: $shared['link'];
-                       $id = self::fetchByLink($url);
-                       if (!$id) {
-                               Logger::notice('Post could not be fetched.', ['url' => $url, 'uid' => $uid]);
-                               return 0;
-                       }
+               $url = $shared['message_id'] ?: $shared['link'];
+               $id = self::fetchByLink($url);
+               if (!$id) {
+                       Logger::notice('Post could not be fetched.', ['url' => $url, 'uid' => $uid]);
+                       return 0;
+               }
 
+               $shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
+               if (!DBA::isResult($shared_item)) {
+                       Logger::warning('Post does not exist.', ['id' => $id, 'url' => $url, 'uid' => $uid]);
+                       return 0;
+               } else {
                        Logger::debug('Fetched shared post', ['id' => $id, 'url' => $url, 'uid' => $uid]);
-
-                       $shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
-                       if (!DBA::isResult($shared_item)) {
-                               Logger::warning('Post does not exist.', ['id' => $id, 'url' => $url, 'uid' => $uid]);
-                               return 0;
-                       }
                }
 
                return $shared_item['uri-id'];