$r=q("SELECT `body`, `tag`, `app`, `created`, `author-link`, `plink` FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
$r=q("SELECT `body`, `tag`, `app`, `created`, `plink`, `object`, `object-type`, `uri` FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
dbesc($orig_guid),
dbesc(NETWORK_DIASPORA)
);
if(count($r)){
logger('reshared message '.$orig_guid." reshared by ".$guid.' already exists on system: '.$orig_url);
logger('reshared message '.$orig_guid." reshared by ".$guid.' already exists on system.');
// Maybe it is already a reshared item?
// Then refetch the content, since there can be many side effects with reshared posts from other networks or reshares from reshares
@ -1102,9 +1136,10 @@ function diaspora_reshare($importer,$xml,$msg) {
@ -120,8 +151,9 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
if($first_id==""){
$first_id=$single_conv->id;
$new_parents=q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
intval($message["uid"]),dbesc($first_id));
$new_parents=q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s') LIMIT 1",
intval($message["uid"]),dbesc($first_id),
dbesc(NETWORK_OSTATUS),dbesc(NETWORK_DFRN));
if($new_parents){
$parent=$new_parents[0];
logger('adopting new parent '.$parent["id"].' for '.$itemid);
@ -136,12 +168,21 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
else
$parent_uri=$parent["uri"];
$message_exists=q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
intval($message["uid"]),dbesc($single_conv->id));
$message_exists=q("SELECT `id` FROM `item` WHERE `uid` = %d AND `plink` = '%s' AND `network` IN ('%s','%s') LIMIT 1",
intval($message["uid"]),dbesc($plink),
dbesc(NETWORK_OSTATUS),dbesc(NETWORK_DFRN));
if(!$message_exists)
$message_exists=q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s') LIMIT 1",
intval($message["uid"]),dbesc($single_conv->id),
dbesc(NETWORK_OSTATUS),dbesc(NETWORK_DFRN));
if($message_exists){
if($parent["id"]!=0){
$existing_message=$message_exists[0];
logger('updating id '.$existing_message["id"].' to parent '.$parent["id"].' uri '.$parent["uri"].' thread '.$parent_uri,LOGGER_DEBUG);
// This is partly bad, since the entry in the thread table isn't updated
$r=q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `thr-parent` = '%s' WHERE `id` = %d",
intval($parent["id"]),
@ -152,21 +193,32 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
continue;
}
$actor=$single_conv->actor->id;
if(isset($single_conv->actor->url))
$actor=$single_conv->actor->url;
$contact=q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",