diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 17 | ||||
-rw-r--r-- | protocols/FacebookRM/src/requests/history.h | 40 | ||||
-rw-r--r-- | protocols/FacebookRM/src/requests/messages.h | 7 |
3 files changed, 44 insertions, 20 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) diff --git a/protocols/FacebookRM/src/requests/history.h b/protocols/FacebookRM/src/requests/history.h index 426266c569..32496340a0 100644 --- a/protocols/FacebookRM/src/requests/history.h +++ b/protocols/FacebookRM/src/requests/history.h @@ -37,8 +37,14 @@ public: setCommonBody(fc); - const char *type = isChat ? "thread_ids" : "user_ids"; - ptrA idEncoded(mir_urlEncode(id)); + const char *type = isChat ? "thread_fbids" : "user_ids"; + std::string id_ = id; // FIXME: Rewrite this without std::string... + if (isChat) { + // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId + if (id_.substr(0, 3) == "id.") + id_ = id_.substr(3); + } + ptrA idEncoded(mir_urlEncode(id_.c_str())); //if (loadMessages) { // Grrr, offset doesn't work at all, we need to use timestamps to get back in history... @@ -65,8 +71,14 @@ public: setCommonBody(fc); - const char *type = isChat ? "thread_ids" : "user_ids"; - ptrA idEncoded(mir_urlEncode(id)); + const char *type = isChat ? "thread_fbids" : "user_ids"; + std::string id_ = id; // FIXME: Rewrite this without std::string... + if (isChat) { + // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId + if (id_.substr(0, 3) == "id.") + id_ = id_.substr(3); + } + ptrA idEncoded(mir_urlEncode(id_.c_str())); // Load only thread info Body << CMStringA(::FORMAT, "threads[%s][0]=%s", type, idEncoded).c_str(); @@ -81,8 +93,14 @@ public: setCommonBody(fc); - const char *type = isChat ? "thread_ids" : "user_ids"; - ptrA idEncoded(mir_urlEncode(id)); + const char *type = isChat ? "thread_fbids" : "user_ids"; + std::string id_ = id; // FIXME: Rewrite this without std::string... + if (isChat) { + // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId + if (id_.substr(0, 3) == "id.") + id_ = id_.substr(3); + } + ptrA idEncoded(mir_urlEncode(id_.c_str())); // Load messages CMStringA begin(::FORMAT, "messages[%s][%s]", type, idEncoded); @@ -106,17 +124,21 @@ public: setCommonBody(fc); for (int i = 0; i < ids.getCount(); i++) { - ptrA idEncoded(mir_urlEncode(ids[i])); + // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId + std::string id_ = ids[i]; // FIXME: Rewrite this without std::string... + if (id_.substr(0, 3) == "id.") + id_ = id_.substr(3); + ptrA idEncoded(mir_urlEncode(id_.c_str())); // Load messages - CMStringA begin(::FORMAT, "messages[%s][%s]", "thread_ids", idEncoded); + CMStringA begin(::FORMAT, "messages[%s][%s]", "thread_fbids", idEncoded); Body << CMStringA(::FORMAT, "%s[offset]=%i", begin, offset).c_str() //<< CMStringA(::FORMAT, "%s[timestamp]=%s", begin, "").c_str() << CMStringA(::FORMAT, "%s[limit]=%i", begin, limit).c_str(); // Load thread info - Body << CMStringA(::FORMAT, "threads[%s][%i]=%s", "thread_ids", i, idEncoded).c_str(); + Body << CMStringA(::FORMAT, "threads[%s][%i]=%s", "thread_fbids", i, idEncoded).c_str(); } } diff --git a/protocols/FacebookRM/src/requests/messages.h b/protocols/FacebookRM/src/requests/messages.h index bc6c41784d..d2e468a6f9 100644 --- a/protocols/FacebookRM/src/requests/messages.h +++ b/protocols/FacebookRM/src/requests/messages.h @@ -146,7 +146,12 @@ public: << "__a=1"; for (int i = 0; i < ids.getCount(); i++) { - CMStringA id(::FORMAT, "ids[%s]=true", ptrA(mir_urlEncode(ids[i]))); + std::string id_ = ids[i]; + // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId + if (id_.substr(0, 3) == "id.") + id_ = id_.substr(3); + + CMStringA id(::FORMAT, "ids[%s]=true", ptrA(mir_urlEncode(id_.c_str()))); Body << id.c_str(); } |