]> git.mxchange.org Git - friendica.git/commitdiff
API Bugfix: This fixes the problem that posts to AndStatus appeared as empty posts
authorMichael Vogel <icarus@dabo.de>
Sat, 7 Nov 2015 13:36:00 +0000 (14:36 +0100)
committerMichael Vogel <icarus@dabo.de>
Sat, 7 Nov 2015 13:36:00 +0000 (14:36 +0100)
include/api.php

index 2fd7d6d45a0999a32b7aa8130a152c61653f4247..35ebaef0341994589d4c51a5437ecd05ca9c71af 100644 (file)
                        $author = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
                                dbesc(normalise_link($item['author-link'])));
                } else if ($item["author-link"].$item["author-name"] != $author[0]["url"].$author[0]["name"]) {
-                       q("UPDATE unique_contacts SET name = '%s', avatar = '%s' WHERE url = '%s'",
-                       dbesc($item["author-name"]), dbesc($item["author-avatar"]), dbesc(normalise_link($item["author-link"])));
+                       q("UPDATE unique_contacts SET name = '%s', avatar = '%s' WHERE (`name` != '%s' OR `avatar` != '%s') AND url = '%s'",
+                       dbesc($item["author-name"]), dbesc($item["author-avatar"]),
+                       dbesc($item["author-name"]), dbesc($item["author-avatar"]),
+                       dbesc(normalise_link($item["author-link"])));
                }
 
                $owner = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
                        $owner = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
                                dbesc(normalise_link($item['owner-link'])));
                } else if ($item["owner-link"].$item["owner-name"] != $owner[0]["url"].$owner[0]["name"]) {
-                       q("UPDATE unique_contacts SET name = '%s', avatar = '%s' WHERE url = '%s'",
-                       dbesc($item["owner-name"]), dbesc($item["owner-avatar"]), dbesc(normalise_link($item["owner-link"])));
+                       q("UPDATE unique_contacts SET name = '%s', avatar = '%s' WHERE (`name` != '%s' OR `avatar` != '%s') AND url = '%s'",
+                       dbesc($item["owner-name"]), dbesc($item["owner-avatar"]),
+                       dbesc($item["owner-name"]), dbesc($item["owner-avatar"]),
+                       dbesc(normalise_link($item["owner-link"])));
                }
 
                // Comments in threads may appear as wall-to-wall postings.
 
                logger('api_status_show: user_info: '.print_r($user_info, true), LOGGER_DEBUG);
 
+               if ($type == "raw")
+                       $privacy_sql = "AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''";
+               else
+                       $privacy_sql = "";
+
                // get last public wall message
                $lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `i`.`author-link` AS `item-author`
                                FROM `item`, `item` as `i`
                                WHERE `item`.`contact-id` = %d AND `item`.`uid` = %d
                                        AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s')))
                                        AND `i`.`id` = `item`.`parent`
-                                       AND `item`.`type`!='activity'
-                                       AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''
+                                       AND `item`.`type`!='activity' $privacy_sql
                                ORDER BY `item`.`created` DESC
                                LIMIT 1",
                                intval($user_info['cid']),
                                $in_reply_to_screen_name = NULL;
                        }
 
-                       $converted = api_convert_item($item);
+                       $converted = api_convert_item($lastwall);
 
                        $status_info = array(
                                'created_at' => api_date($lastwall['created']),
                        unset($status_info["user"]["self"]);
                }
 
+               logger('status_info: '.print_r($status_info, true), LOGGER_DEBUG);
+
                if ($type == "raw")
                        return($status_info);
 
                                }
                        }
 
-                       $converted = api_convert_item($item);
+                       $converted = api_convert_item($lastwall);
 
                        $user_info['status'] = array(
                                'text' => $converted["text"],
@@ -2877,8 +2887,8 @@ function api_get_nick($profile) {
        //}
 
        if ($nick != "") {
-               q("UPDATE unique_contacts SET nick = '%s' WHERE url = '%s'",
-                       dbesc($nick), dbesc(normalise_link($profile)));
+               q("UPDATE unique_contacts SET nick = '%s' WHERE `nick` != '%s' AND url = '%s'",
+                       dbesc($nick), dbesc($nick), dbesc(normalise_link($profile)));
                return($nick);
        }