Ensure local delivery of Diaspora comments

This commit is contained in:
Michael 2018-04-27 04:11:33 +00:00
parent e3c9d31088
commit 1e2bc1e6cf

View file

@ -866,7 +866,6 @@ class Item extends BaseObject
unset($item['mention']); unset($item['mention']);
unset($item['wall']); unset($item['wall']);
unset($item['origin']); unset($item['origin']);
unset($item['global']);
unset($item['starred']); unset($item['starred']);
unset($item['rendered-hash']); unset($item['rendered-hash']);
unset($item['rendered-html']); unset($item['rendered-html']);
@ -976,10 +975,15 @@ class Item extends BaseObject
if (!dba::exists('item', ['uri' => $item['uri'], 'uid' => 0])) { if (!dba::exists('item', ['uri' => $item['uri'], 'uid' => 0])) {
// Preparing public shadow (removing user specific data) // Preparing public shadow (removing user specific data)
unset($item['id']);
$item['uid'] = 0; $item['uid'] = 0;
$item['origin'] = 0; unset($item['id']);
$item['wall'] = 0; 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']) { if ($item['uri'] == $item['parent-uri']) {
$item['contact-id'] = Contact::getIdForURL($item['owner-link']); $item['contact-id'] = Contact::getIdForURL($item['owner-link']);
} else { } else {
@ -1033,11 +1037,20 @@ class Item extends BaseObject
return; return;
} }
// Save "origin" and "parent" state
$origin = $item['origin'];
$parent = $item['parent'];
// Preparing public shadow (removing user specific data) // Preparing public shadow (removing user specific data)
unset($item['id']);
$item['uid'] = 0; $item['uid'] = 0;
$item['origin'] = 0; unset($item['id']);
$item['wall'] = 0; 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']); $item['contact-id'] = Contact::getIdForURL($item['author-link']);
if (in_array($item['type'], ["net-comment", "wall-comment"])) { 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); $public_shadow = self::insert($item, false, false, true);
logger("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, LOGGER_DEBUG); 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);
}
}
} }
/** /**