From 9222cf1c6c5880bcd29f54be0e7c37cce1df574a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Sun, 6 Jul 2014 09:00:17 +0000 Subject: Facebook: Fix creating duplicit contacts on window open (it's ugly, must be fixed better later) git-svn-id: http://svn.miranda-ng.org/main/trunk@9700 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/json.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'protocols/FacebookRM/src') diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index d0ff3ad01a..782fb3b40c 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -795,6 +795,7 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo 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 *thread_fbid = json_get(it, "thread_fbid"); JSONNODE *name = json_get(it, "name"); //JSONNODE *message_count = json_get(it, "message_count"); JSONNODE *unread_count = json_get(it, "unread_count"); // TODO: use it to check against number of loaded messages... but how? @@ -805,7 +806,9 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo std::string id = json_as_pstring(canonical); std::string tid = json_as_pstring(thread_id); + std::string tfbid = json_as_pstring(thread_fbid); + // FIXME: fix this ugliness better (it was quick workaround for stable release) std::map::iterator iter = chatrooms->find(tid); if (iter != chatrooms->end()) { if (json_as_bool(is_canonical_user)) { @@ -815,6 +818,22 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo } } + iter = chatrooms->find(tfbid); + 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... + } + } + + iter = chatrooms->find(id); + if (iter != chatrooms->end()) { + chatrooms->erase(iter); // this is not chatroom + } + // END OF FIXME + if (inboxOnly && json_as_pstring(folder) != "inbox") continue; -- cgit v1.2.3