require_once('include/contact_selectors.php');
require_once('include/queue_fn.php');
require_once('include/lock.php');
+require_once('include/threads.php');
function diaspora_dispatch_public($msg) {
array($remote_photo_name, 'scaled_full_' . $remote_photo_name));
if(strpos($parent_item['body'],$link_text) === false) {
- $r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d",
+ $r = q("UPDATE `item` SET `body` = '%s', `visible` = 1 WHERE `id` = %d AND `uid` = %d",
dbesc($link_text . $parent_item['body']),
intval($parent_item['id']),
intval($parent_item['uid'])
);
+ update_thread($parent_item['id']);
}
return;
));
logger('item_store: Notification sent for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
}
- } else
+ } else {
update_thread($parent_id);
+ add_shadow_entry($arr);
+ }
if ($notify)
proc_run('php', "include/notifier.php", $notify_type, $current_post);
}
}
+function add_shadow_entry($item) {
+
+ // Is this a shadow entry?
+ if ($item['uid'] == 0)
+ return;
+
+ // Is there a shadow parent?
+ $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['parent-uri']));
+ if (!count($r))
+ return;
+
+ // Is there already a shadow entry?
+ $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri']));
+
+ if (count($r))
+ return;
+
+ // Preparing public shadow (removing user specific data)
+ require_once("include/items.php");
+ require_once("include/Contact.php");
+
+ unset($item['id']);
+ $item['uid'] = 0;
+ $item['contact-id'] = get_contact($item['author-link'], 0);
+ $public_shadow = item_store($item, false, false, true);
+
+ logger("Stored public shadow for comment ".$item['uri']." under id ".$public_shadow, LOGGER_DEBUG);
+}
+
function update_thread_uri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
`author-name` AS `name`, `owner-avatar` AS `photo`,
`owner-link` AS `url`, `owner-avatar` AS `thumb`
- FROM `item` WHERE `item`.`uid` = 0
+ FROM `item` WHERE `item`.`uid` = 0 AND `item`.`id` = `item`.`parent`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
ORDER BY `item`.`received` DESC LIMIT %d, %d",