From 238b972449ff00de1ab606db730d1d6e4a6fe8f7 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Nov 2020 09:42:28 -0500 Subject: [PATCH] [various] Replace confusing uses of item.parent-uri with expected item.thr-parent --- pumpio/pumpio.php | 8 ++++---- statusnet/statusnet.php | 22 ++++++---------------- twitter/twitter.php | 25 +++++++------------------ 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index cd44b682e..b20b0f949 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -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; diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 05853025a..80579173c 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -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; } diff --git a/twitter/twitter.php b/twitter/twitter.php index 83731943d..f70aa141b 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -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);