]> git.mxchange.org Git - friendica.git/commitdiff
Ensure local delivery of Diaspora comments
authorMichael <heluecht@pirati.ca>
Fri, 27 Apr 2018 04:11:33 +0000 (04:11 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 27 Apr 2018 04:11:33 +0000 (04:11 +0000)
src/Model/Item.php

index aa3800cbe175c55c5897969a36f9bf9d97f32926..e7fd115dd131f32aea4d3079ba6816f6855fad82 100644 (file)
@@ -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);
+                       }
+               }
        }
 
         /**