From 1e2bc1e6cfc298ba71b80f7895c2c6da29871f93 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 27 Apr 2018 04:11:33 +0000 Subject: [PATCH] Ensure local delivery of Diaspora comments --- src/Model/Item.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index aa3800cbe..e7fd115dd 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -866,7 +866,6 @@ class Item extends BaseObject unset($item['mention']); unset($item['wall']); unset($item['origin']); - unset($item['global']); unset($item['starred']); unset($item['rendered-hash']); unset($item['rendered-html']); @@ -976,10 +975,15 @@ class Item extends BaseObject if (!dba::exists('item', ['uri' => $item['uri'], 'uid' => 0])) { // Preparing public shadow (removing user specific data) - unset($item['id']); $item['uid'] = 0; - $item['origin'] = 0; - $item['wall'] = 0; + unset($item['id']); + unset($item['parent']); + unset($item['wall']); + unset($item['mention']); + unset($item['origin']); + unset($item['starred']); + unset($item['rendered-hash']); + unset($item['rendered-html']); if ($item['uri'] == $item['parent-uri']) { $item['contact-id'] = Contact::getIdForURL($item['owner-link']); } else { @@ -1033,11 +1037,20 @@ class Item extends BaseObject return; } + // Save "origin" and "parent" state + $origin = $item['origin']; + $parent = $item['parent']; + // Preparing public shadow (removing user specific data) - unset($item['id']); $item['uid'] = 0; - $item['origin'] = 0; - $item['wall'] = 0; + unset($item['id']); + unset($item['parent']); + unset($item['wall']); + unset($item['mention']); + unset($item['origin']); + unset($item['starred']); + unset($item['rendered-hash']); + unset($item['rendered-html']); $item['contact-id'] = Contact::getIdForURL($item['author-link']); if (in_array($item['type'], ["net-comment", "wall-comment"])) { @@ -1049,6 +1062,14 @@ class Item extends BaseObject $public_shadow = self::insert($item, false, false, true); logger("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, LOGGER_DEBUG); + + // If this was a comment to a Diaspora post we don't get our comment back. + // This means that we have to distribute the comment by ourselves. + if ($origin) { + if (dba::exists('item', ['id' => $parent, 'network' => NETWORK_DIASPORA])) { + self::distribute($public_shadow); + } + } } /**