From ac35f8c756a85cd36c8c2c2df7b7306056443f49 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 23 Mar 2016 09:22:59 +0100 Subject: [PATCH] If the message already exists then the message id should be returned --- include/diaspora.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index b339e73157..308a799118 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -755,8 +755,8 @@ class diaspora { * * @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", @@ -766,7 +766,7 @@ class diaspora { if($r) { logger("message ".$guid." already exists for user ".$uid); - return true; + return $r[0]["id"]; } return false; @@ -1028,8 +1028,9 @@ class diaspora { 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) @@ -1357,8 +1358,9 @@ class diaspora { 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) @@ -1926,8 +1928,9 @@ class diaspora { 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) @@ -2110,8 +2113,9 @@ class diaspora { 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) -- 2.39.5