summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-02-28 13:37:57 +0000
committerRobert Pösel <robyer@seznam.cz>2014-02-28 13:37:57 +0000
commit60e837970d17d60c2af0a1b5351107d2dba31031 (patch)
treec9d30c8400befe433f83c3441c2c5880aa3c3413 /protocols
parentc95380f9b30137a01b776f0390438908f47cc848 (diff)
Facebook: Fix loading unread (offline) messages
git-svn-id: http://svn.miranda-ng.org/main/trunk@8326 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/src/json.cpp22
1 files changed, 14 insertions, 8 deletions
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<std::string, std::string> 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<std::string, facebook_chatroom*>::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<std::string, facebook_chatroom*>::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));
}