]> git.mxchange.org Git - friendica.git/commitdiff
If the message already exists then the message id should be returned
authorMichael Vogel <icarus@dabo.de>
Wed, 23 Mar 2016 08:22:59 +0000 (09:22 +0100)
committerMichael Vogel <icarus@dabo.de>
Wed, 23 Mar 2016 08:22:59 +0000 (09:22 +0100)
include/diaspora.php

index b339e73157253e5669e70d2ba4eade8e6f251fe7..308a799118a819416e509066d7b89a4755a6c0d1 100644 (file)
@@ -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)