]> git.mxchange.org Git - friendica-addons.git/commitdiff
[various] Replace confusing uses of item.parent-uri with expected item.thr-parent
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 11 Nov 2020 14:42:28 +0000 (09:42 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 11 Nov 2020 14:42:28 +0000 (09:42 -0500)
pumpio/pumpio.php
statusnet/statusnet.php
twitter/twitter.php

index cd44b682e6ddf5e760cd65ade8e4ed152cee7252..b20b0f9496c601ed20fc2463a2ed927528ea1829 100644 (file)
@@ -966,7 +966,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
        $likedata['wall'] = 0;
        $likedata['network'] = Protocol::PUMPIO;
        $likedata['uri'] = Item::newURI($uid);
-       $likedata['parent-uri'] = $orig_post["uri"];
+       $likedata['thr-parent'] = $orig_post['uri'];
        $likedata['contact-id'] = $contactid;
        $likedata['app'] = $post->generator->displayName;
        $likedata['author-name'] = $post->actor->displayName;
@@ -1137,7 +1137,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
                        $contact_id = $self[0]['id'];
                }
 
-               $postarray['parent-uri'] = $post->object->id;
+               $postarray['thr-parent'] = $post->object->id;
 
                if (!$public) {
                        $postarray['private'] = 1;
@@ -1198,7 +1198,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
                $reply->url = $post->object->inReplyTo->url;
                pumpio_dopost($a, $client, $uid, $self, $reply, $own_id, false);
 
-               $postarray['parent-uri'] = $post->object->inReplyTo->id;
+               $postarray['thr-parent'] = $post->object->inReplyTo->id;
        }
 
        // When there is no content there is no need to continue
@@ -1277,7 +1277,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
        }
 
        if (($post->object->objectType == "comment") && $threadcompletion) {
-               pumpio_fetchallcomments($a, $uid, $postarray['parent-uri']);
+               pumpio_fetchallcomments($a, $uid, $postarray['thr-parent']);
        }
 
        return $top_item;
index 05853025a5b343fb42ad29a2627bac2ce2c1a835..80579173cc3a45bb3908bed0e88c709d023d5112 100644 (file)
@@ -1104,24 +1104,15 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
        $contactid = 0;
 
        if (!empty($content->in_reply_to_status_id)) {
+               $thr_parent = $hostname . "::" . $content->in_reply_to_status_id;
 
-               $parent = $hostname . "::" . $content->in_reply_to_status_id;
-
-               $fields = ['uri', 'parent-uri', 'parent'];
-               $item = Item::selectFirst($fields, ['uri' => $parent, 'uid' => $uid]);
-
-               if (!DBA::isResult($item)) {
-                       $item = Item::selectFirst($fields, ['extid' => $parent, 'uid' => $uid]);
-               }
-
-               if (DBA::isResult($item)) {
-                       $postarray['thr-parent'] = $item['uri'];
-                       $postarray['parent-uri'] = $item['parent-uri'];
-                       $postarray['parent'] = $item['parent'];
+               if (
+                       Item::exists(['uri' => $thr_parent, 'uid' => $uid])
+                       || Item::exists(['extid' => $thr_parent, 'uid' => $uid])
+               ) {
+                       $postarray['thr-parent'] = $thr_parent;
                        $postarray['object-type'] = Activity\ObjectType::COMMENT;
                } else {
-                       $postarray['thr-parent'] = $postarray['uri'];
-                       $postarray['parent-uri'] = $postarray['uri'];
                        $postarray['object-type'] = Activity\ObjectType::NOTE;
                }
 
@@ -1145,7 +1136,6 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
                // Don't create accounts of people who just comment something
                $create_user = false;
        } else {
-               $postarray['parent-uri'] = $postarray['uri'];
                $postarray['object-type'] = Activity\ObjectType::NOTE;
        }
 
index 83731943d2f30901f8d457788b5920296509510d..f70aa141b4656556f4add9683805e3efc215a4d4 100644 (file)
@@ -1582,22 +1582,15 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
        $contactid = 0;
 
        if ($post->in_reply_to_status_id_str != "") {
-               $parent = "twitter::" . $post->in_reply_to_status_id_str;
+               $thr_parent = "twitter::" . $post->in_reply_to_status_id_str;
 
-               $fields = ['uri', 'parent-uri', 'parent'];
-               $parent_item = Item::selectFirst($fields, ['uri' => $parent, 'uid' => $uid]);
-               if (!DBA::isResult($parent_item)) {
-                       $parent_item = Item::selectFirst($fields, ['extid' => $parent, 'uid' => $uid]);
-               }
-
-               if (DBA::isResult($parent_item)) {
-                       $postarray['thr-parent'] = $parent_item['uri'];
-                       $postarray['parent-uri'] = $parent_item['parent-uri'];
-                       $postarray['parent'] = $parent_item['parent'];
+               if (
+                       Item::exists(['uri' => $thr_parent, 'uid' => $uid])
+                       || Item::exists(['extid' => $thr_parent, 'uid' => $uid])
+               ) {
+                       $postarray['thr-parent'] = $thr_parent;
                        $postarray['object-type'] = Activity\ObjectType::COMMENT;
                } else {
-                       $postarray['thr-parent'] = $postarray['uri'];
-                       $postarray['parent-uri'] = $postarray['uri'];
                        $postarray['object-type'] = Activity\ObjectType::NOTE;
                }
 
@@ -1622,7 +1615,6 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
                // Don't create accounts of people who just comment something
                $create_user = false;
        } else {
-               $postarray['parent-uri'] = $postarray['uri'];
                $postarray['object-type'] = Activity\ObjectType::NOTE;
        }
 
@@ -1710,9 +1702,6 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
                        $postarray['verb'] = Activity::ANNOUNCE;
                        $postarray['gravity'] = GRAVITY_ACTIVITY;
                        $postarray['object-type'] = Activity\ObjectType::NOTE;
-
-                       $postarray['thr-parent'] = $retweet['uri'];
-                       $postarray['parent-uri'] = $retweet['uri'];
                } else {
                        $retweet['source'] = $postarray['source'];
                        $retweet['private'] = $postarray['private'];
@@ -1930,7 +1919,7 @@ function twitter_fetchhometimeline(App $a, $uid)
 
                        $notify = false;
 
-                       if (($postarray['uri'] == $postarray['parent-uri']) && ($postarray['author-link'] == $postarray['owner-link'])) {
+                       if (($postarray['uri'] == $postarray['thr-parent']) && ($postarray['author-link'] == $postarray['owner-link'])) {
                                $contact = DBA::selectFirst('contact', [], ['id' => $postarray['contact-id'], 'self' => false]);
                                if (DBA::isResult($contact)) {
                                        $notify = Item::isRemoteSelf($contact, $postarray);