diff options
author | matej <matej.vavrek@m2ms.sk> | 2018-01-13 12:14:10 +0100 |
---|---|---|
committer | matej <matej.vavrek@m2ms.sk> | 2018-01-13 12:14:10 +0100 |
commit | 9c91983ceca6bb8446b92129751f6f481a329249 (patch) | |
tree | ace8f07c34fefe2e321f265291f012af30936aa6 /protocols/FacebookRM | |
parent | 6bc16395b7033d7d6225f83928cbbec225ccbe01 (diff) |
Facebook: fix for loading multiple unread messages at once at startup
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 13 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 02775b85f3..616b77c833 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -1165,11 +1165,20 @@ int FacebookProto::ParseUnreadThreads(std::string *data, std::vector< std::strin int FacebookProto::ParseThreadMessages(std::string *data, std::vector< facebook_message >* messages, bool unreadOnly) { - // cuts out the rest - size_t len = data->find("\r\n"); + // cuts out the rest (summary result) + size_t len = data->find("\r\n{\n \"successful_results"); if (len != data->npos) data->erase(len); + // make data to be valid json (queries are standalone JSONs --> merge them into one) + std::string::size_type n = 0; + std::string replaceFrom = "}\r\n{"; + std::string replaceTo = ", "; + while ((n = data->find(replaceFrom, n)) != std::string::npos) { + data->replace(n, replaceFrom.size(), replaceTo); + n += replaceTo.size(); + } + JSONNode root = JSONNode::parse(data->c_str()); if (!root) return EXIT_FAILURE; diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index c5108ddf5b..7b10449615 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -316,7 +316,7 @@ void FacebookProto::LoadHistory(void *pParam) } // first get info about this thread and how many messages is there - http::response resp = facy.sendRequest(facy.threadInfoRequest(isChat, item_id)); + http::response resp = facy.sendRequest(facy.threadInfoRequest(isChat, (char*)item_id)); if (resp.code != HTTP_CODE_OK || resp.data.empty()) { facy.handle_error("LoadHistory"); return; |