}
}
+ // If there is no guid then take the same guid that was taken before for the same plink
+ if ((trim($arr['guid']) == "") AND (trim($arr['plink']) != "")) {
+ logger('item_store: checking for an existing guid for plink '.$arr['plink'], LOGGER_DEBUG);
+ $r = q("SELECT `guid` FROM `item` WHERE `plink` = '%s' AND `guid` != '' LIMIT 1",
+ dbesc(trim($arr['plink']))
+ );
+
+ if(count($r)) {
+ $arr['guid'] = $r[0]["guid"];
+ logger('item_store: found guid '.$arr['guid'].' for plink '.$arr['plink'], LOGGER_DEBUG);
+ }
+ }
+
// Shouldn't happen but we want to make absolutely sure it doesn't leak from a plugin.
// Deactivated, since the bbcode parser can handle with it - and it destroys posts with some smileys that contain "<"
//if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
}
}
- $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
dbesc($arr['uri']),
+ dbesc($arr['network']),
intval($arr['uid'])
);
-
if($r && count($r)) {
logger('duplicated item with the same uri found. ' . print_r($arr,true));
return 0;
- } else {
- // Check for an existing post with the same content. There seems to be a problem with OStatus.
- $r = q("SELECT `id` FROM `item` WHERE `body` = '%s' AND `created` = '%s' AND `contact-id` = %d AND `uid` = %d LIMIT 1",
- dbesc($arr['body']),
- dbesc($arr['created']),
- intval($arr['contact-id']),
- intval($arr['uid'])
- );
- if($r && count($r)) {
- logger('duplicated item with the same body found. ' . print_r($arr,true));
- return 0;
- }
+ }
+
+ $r = q("SELECT `id` FROM `item` WHERE `plink` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($arr['plink']),
+ dbesc($arr['network']),
+ intval($arr['uid'])
+ );
+ if($r && count($r)) {
+ logger('duplicated item with the same plink found. ' . print_r($arr,true));
+ return 0;
+ }
+
+ // Check for an existing post with the same content. There seems to be a problem with OStatus.
+ $r = q("SELECT `id` FROM `item` WHERE `body` = '%s' AND `network` = '%s' AND `created` = '%s' AND `contact-id` = %d AND `uid` = %d LIMIT 1",
+ dbesc($arr['body']),
+ dbesc($arr['network']),
+ dbesc($arr['created']),
+ intval($arr['contact-id']),
+ intval($arr['uid'])
+ );
+ if($r && count($r)) {
+ logger('duplicated item with the same body found. ' . print_r($arr,true));
+ return 0;
}
// Is this item available in the global items (with uid=0)?
$plink = $single_conv->provider->url."notice/".$single_conv->statusnet_notice_info->local_id;
elseif (isset($single_conv->provider->url) AND isset($single_conv->statusnet->notice_info->local_id))
$plink = $single_conv->provider->url."notice/".$single_conv->statusnet->notice_info->local_id;
+ elseif (isset($single_conv->provider->url) AND isset($single_conv->status_net->notice_info->local_id))
+ $plink = $single_conv->provider->url."notice/".$single_conv->status_net->notice_info->local_id;
if (@!$single_conv->id)
continue;
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);
else
$parent_uri = $parent["uri"];
- $message_exists = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `plink` = '%s' LIMIT 1",
- intval($message["uid"]), dbesc($plink));
+ $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' LIMIT 1",
- intval($message["uid"]), dbesc($single_conv->id));
+ $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"]),
$arr["author-avatar"] = $single_conv->actor->image->url;
$arr["body"] = html2bbcode($single_conv->content);
- if (isset($single_conv->statusnet->notice_info->source))
+ if (isset($single_conv->status_net->notice_info->source))
+ $arr["app"] = strip_tags($single_conv->status_net->notice_info->source);
+ elseif (isset($single_conv->statusnet->notice_info->source))
$arr["app"] = strip_tags($single_conv->statusnet->notice_info->source);
elseif (isset($single_conv->statusnet_notice_info->source))
$arr["app"] = strip_tags($single_conv->statusnet_notice_info->source);