From 5998c3995e745d0c2a3b60fab66c5ba9e2b9c27f Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 6 Oct 2020 18:47:23 +0000 Subject: [PATCH 1/3] Issue-9358 (now for real) commenting and updating on contact now work --- include/conversation.php | 4 ++-- mod/update_contact.php | 5 ++--- src/Model/Contact.php | 20 +++++++++++++------- src/Module/Contact.php | 13 +++++++------ 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 1e8437f71..c2226fa35 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -452,8 +452,8 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o $profile_owner = 0; if (!$update) { - $live_update_div = '
' . "\r\n" - . "\r\n"; } } elseif ($mode === 'search') { diff --git a/mod/update_contact.php b/mod/update_contact.php index 4863ad02d..3f8e00b29 100644 --- a/mod/update_contact.php +++ b/mod/update_contact.php @@ -28,11 +28,10 @@ use Friendica\Module\Contact; function update_contact_content(App $a) { - if (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update')) { - $text = Contact::content([], true); + if (!empty($a->argv[1]) && (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update'))) { + $text = Contact::getConversationsHMTL($a, $a->argv[1], true, ($_GET['item'] ?? 0)); } else { $text = ''; } - System::htmlUpdateExit($text); } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index e997bffde..41c68bda8 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1248,12 +1248,13 @@ class Contact * @param string $contact_url Contact URL * @param bool $thread_mode * @param int $update + * @param int $parent * @return string posts in HTML * @throws \Exception */ - public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0) + public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0, $parent = 0) { - return self::getPostsFromId(self::getIdForURL($contact_url), $thread_mode, $update); + return self::getPostsFromId(self::getIdForURL($contact_url), $thread_mode, $update, $parent); } /** @@ -1262,10 +1263,11 @@ class Contact * @param integer $cid * @param bool $thread_mode * @param integer $update + * @param int $parent * @return string posts in HTML * @throws \Exception */ - public static function getPostsFromId($cid, $thread_mode = false, $update = 0) + public static function getPostsFromId($cid, $thread_mode = false, $update = 0, $parent = 0) { $a = DI::app(); @@ -1290,9 +1292,13 @@ class Contact $cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()]; } - $last_received = isset($_GET['last_received']) ? DateTimeFormat::utc($_GET['last_received']) : ''; - if (!empty($last_received)) { - $condition = DBA::mergeConditions($condition, ["`received` < ?", $last_received]); + if (!empty($parent)) { + $condition = DBA::mergeConditions($condition, ['parent' => $parent]); + } else { + $last_received = isset($_GET['last_received']) ? DateTimeFormat::utc($_GET['last_received']) : ''; + if (!empty($last_received)) { + $condition = DBA::mergeConditions($condition, ["`received` < ?", $last_received]); + } } if (DI::mode()->isMobile()) { @@ -1335,7 +1341,7 @@ class Contact $items = Item::inArray($r); - $o .= conversation($a, $items, 'contact-posts', false); + $o .= conversation($a, $items, 'contact-posts', $update); } if (!$update) { diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 659380fbe..cc4f4d9ab 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -921,7 +921,7 @@ class Contact extends BaseModule return $tab_str; } - private static function getConversationsHMTL($a, $contact_id, $update) + public static function getConversationsHMTL($a, $contact_id, $update, $parent = 0) { $o = ''; @@ -952,14 +952,15 @@ class Contact extends BaseModule if (DBA::isResult($contact)) { DI::page()['aside'] = ''; - $profiledata = Model\Contact::getByURLForUser($contact['url'], local_user()); - - Model\Profile::load($a, '', $profiledata, true); + if (!$update) { + $profiledata = Model\Contact::getByURLForUser($contact['url'], local_user()); + Model\Profile::load($a, '', $profiledata, true); + } if ($contact['uid'] == 0) { - $o .= Model\Contact::getPostsFromId($contact['id'], true, $update); + $o .= Model\Contact::getPostsFromId($contact['id'], true, $update, $parent); } else { - $o .= Model\Contact::getPostsFromUrl($contact['url'], true, $update); + $o .= Model\Contact::getPostsFromUrl($contact['url'], true, $update, $parent); } } From 5580b148a67898f023c144bff1e2befc5bbafe3c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 6 Oct 2020 19:51:51 +0000 Subject: [PATCH 2/3] Added description --- src/Model/Contact.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 41c68bda8..eb21708ed 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1245,10 +1245,10 @@ class Contact /** * Returns posts from a given contact url * - * @param string $contact_url Contact URL - * @param bool $thread_mode - * @param int $update - * @param int $parent + * @param string $contact_url Contact URL + * @param bool $thread_mode + * @param integer $update Update mode + * @param int $parent Parent ID for the update mode * @return string posts in HTML * @throws \Exception */ @@ -1260,10 +1260,10 @@ class Contact /** * Returns posts from a given contact id * - * @param integer $cid + * @param integer $cid Contact ID * @param bool $thread_mode - * @param integer $update - * @param int $parent + * @param integer $update Update mode + * @param int $parent Parent ID for the update mode * @return string posts in HTML * @throws \Exception */ From bb676f780c55c2a7b82111115f2fb75d4922364b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 6 Oct 2020 20:36:57 +0000 Subject: [PATCH 3/3] Changed documentation --- src/Model/Contact.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index eb21708ed..6bbc0921c 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1245,10 +1245,10 @@ class Contact /** * Returns posts from a given contact url * - * @param string $contact_url Contact URL - * @param bool $thread_mode - * @param integer $update Update mode - * @param int $parent Parent ID for the update mode + * @param string $contact_url Contact URL + * @param bool $thread_mode + * @param int $update Update mode + * @param int $parent Item parent ID for the update mode * @return string posts in HTML * @throws \Exception */ @@ -1260,10 +1260,10 @@ class Contact /** * Returns posts from a given contact id * - * @param integer $cid Contact ID - * @param bool $thread_mode - * @param integer $update Update mode - * @param int $parent Parent ID for the update mode + * @param int $cid Contact ID + * @param bool $thread_mode + * @param int $update Update mode + * @param int $parent Item parent ID for the update mode * @return string posts in HTML * @throws \Exception */