*
* @param int $uid The user id
* @param string $guid The guid of the message
- *
- * @return bool "true" if the message already was stored into the system
+y *
+ * @return int|bool message id if the message already was stored into the system - or false.
*/
private function message_exists($uid, $guid) {
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
if($r) {
logger("message ".$guid." already exists for user ".$uid);
- return true;
+ return $r[0]["id"];
}
return false;
if (!$contact)
return false;
- if (self::message_exists($importer["uid"], $guid))
- return false;
+ $message_id = self::message_exists($importer["uid"], $guid);
+ if ($message_id)
+ return $message_id;
$parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact);
if (!$parent_item)
if (!$contact)
return false;
- if (self::message_exists($importer["uid"], $guid))
- return false;
+ $message_id = self::message_exists($importer["uid"], $guid);
+ if ($message_id)
+ return $message_id;
$parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact);
if (!$parent_item)
if (!$contact)
return false;
- if (self::message_exists($importer["uid"], $guid))
- return false;
+ $message_id = self::message_exists($importer["uid"], $guid);
+ if ($message_id)
+ return $message_id;
$original_item = self::original_item($root_guid, $root_author, $author);
if (!$original_item)
if (!$contact)
return false;
- if (self::message_exists($importer["uid"], $guid))
- return false;
+ $message_id = self::message_exists($importer["uid"], $guid);
+ if ($message_id)
+ return $message_id;
$address = array();
if ($data->location)