diff options
author | Robert Pösel <robyer@seznam.cz> | 2016-12-04 17:49:27 +0100 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2016-12-04 17:53:38 +0100 |
commit | c3476b0dd031a7b85baa138c84e7d5751d67dbf5 (patch) | |
tree | b66334136a49beb28acf6dbc685d365554620461 /protocols/FacebookRM/src/json.cpp | |
parent | b6c0516b0535f9f4dc14cd4c6ea506762d56cf3e (diff) |
Facebook: Fix support for "new" group chats (dirty changes)
This commit is just quick workaround for group chat changes, where Facebook stopped using "id.XXX" ids, and instead use just "XXX" fbids. And for old existing chats tolerates old type, but for new forces this new format.
I don't know how that, or changes in this commit, affects classic conversations, but in any case this commit should be cleaned and integrated better. Perhaps rewrite whole uses of "ids" to "fbids" everywhere.
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 71446f3874..dd4e727f3c 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -1118,12 +1118,8 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector< const JSONNode &roger = payload["roger"]; for (auto it = roger.begin(); it != roger.end(); ++it) { std::string id = (*it).name(); - - // Ignore "wrong" (duplicit) identifiers - these that doesn't begin with "id." - if (id.substr(0, 3) == "id.") { - facebook_chatroom *room = new facebook_chatroom(id); - chatrooms->insert(std::make_pair(id, room)); - } + facebook_chatroom *room = new facebook_chatroom(id); + chatrooms->insert(std::make_pair(id, room)); } std::map<std::string, std::string> thread_ids; @@ -1177,7 +1173,7 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector< const JSONNode &author = (*it)["author"]; const JSONNode &other_user_fbid = (*it)["other_user_fbid"]; const JSONNode &body = (*it)["body"]; - const JSONNode &tid = (*it)["thread_id"]; + const JSONNode &tid = (*it)["thread_fbid"]; const JSONNode &mid = (*it)["message_id"]; const JSONNode ×tamp = (*it)["timestamp"]; const JSONNode &filtered = (*it)["is_filtered_content"]; @@ -1232,6 +1228,7 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector< // this is chatroom message message.isChat = true; message.user_id = author_id; + message.thread_id = "id." + thread_id; } else { // this is standard message @@ -1406,15 +1403,15 @@ int facebook_json_parser::parse_chat_info(std::string *data, facebook_chatroom* for (auto it = threads.begin(); it != threads.end(); ++it) { const JSONNode &is_canonical_user_ = (*it)["is_canonical_user"]; - const JSONNode &thread_id_ = (*it)["thread_id"]; + const JSONNode &thread_fbid_ = (*it)["thread_fbid"]; const JSONNode &name_ = (*it)["name"]; //const JSONNode &message_count_ = (*it)["message_count"); //const JSONNode &unread_count_ = (*it)["unread_count"); // TODO: use it to check against number of loaded messages... but how? - if (!thread_id_ || !is_canonical_user_ || is_canonical_user_.as_bool()) + if (!thread_fbid_ || !is_canonical_user_ || is_canonical_user_.as_bool()) continue; - std::string tid = thread_id_.as_string(); + std::string tid = "id." + thread_fbid_.as_string(); // TODO: allow more chats to parse at once if (fbc->thread_id != tid) |