1
1
Fork 0

If the message already exists then the message id should be returned

This commit is contained in:
Michael Vogel 2016-03-23 09:22:59 +01:00
parent 28dfaa694c
commit ac35f8c756

View file

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