From 60e837970d17d60c2af0a1b5351107d2dba31031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Fri, 28 Feb 2014 13:37:57 +0000 Subject: Facebook: Fix loading unread (offline) messages git-svn-id: http://svn.miranda-ng.org/main/trunk@8326 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/json.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'protocols/FacebookRM/src/json.cpp') diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 4f69ae51e2..ad651a6bc5 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -817,28 +817,34 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo std::map thread_ids; for (unsigned int i = 0; i < json_size(threads); i++) { JSONNODE *it = json_at(threads, i); + JSONNODE *is_canonical_user = json_get(it, "is_canonical_user"); JSONNODE *canonical = json_get(it, "canonical_fbid"); JSONNODE *thread_id = json_get(it, "thread_id"); JSONNODE *name = json_get(it, "name"); JSONNODE *unread_count = json_get(it, "unread_count"); // TODO: use it to check against number of loaded messages... but how? JSONNODE *folder = json_get(it, "folder"); - std::map::iterator iter = chatrooms->find(json_as_pstring(thread_id)); - if (iter != chatrooms->end()) { - iter->second->chat_name = json_as_string(name); // TODO: create name from users if there is no name... - } - if (canonical == NULL || thread_id == NULL) continue; + std::string id = json_as_pstring(canonical); + std::string tid = json_as_pstring(thread_id); + + std::map::iterator iter = chatrooms->find(tid); + if (iter != chatrooms->end()) { + if (json_as_bool(is_canonical_user)) { + chatrooms->erase(iter); // this is not chatroom + } else { + iter->second->chat_name = json_as_string(name); // TODO: create name from users if there is no name... + } + } + if (inboxOnly && json_as_pstring(folder) != "inbox") continue; - std::string id = json_as_pstring(canonical); if (id == "null") continue; - - std::string tid = json_as_pstring(thread_id); + thread_ids.insert(std::make_pair(tid, id)); } -- cgit v1.2.3