diff options
author | ikeblaster <ike@thez.info> | 2019-06-15 14:55:37 +0200 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-06-16 22:40:04 +0300 |
commit | 1418e434c8734277480da28e828705d0336058b8 (patch) | |
tree | 4defa3380d87c3e2764b2dab0765c76f718b64da /protocols/FacebookRM/src/json.cpp | |
parent | 34967c6ad0a420ac99c1b873b569208bdb88782e (diff) |
Facebook - alternative loading of contacts' statuses
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index de642b4186..b6d4797e56 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -1192,6 +1192,36 @@ int FacebookProto::ParseMessages(std::string &pData, std::vector<facebook_messag return EXIT_SUCCESS; } + +int FacebookProto::ParseBuddylistUpdate(std::string* data) +{ + std::string jsonData = data->substr(9); + + JSONNode root = JSONNode::parse(jsonData.c_str()); + if (!root) + return EXIT_FAILURE; + + const JSONNode &buddylist = root["payload"].at("buddylist"); + if (!buddylist) + return EXIT_FAILURE; + + setAllContactStatuses(ID_STATUS_OFFLINE); + + for (auto &it : buddylist) { + const JSONNode &id = it["id"]; + const JSONNode &status = it["status"]; + + // Facebook now sends info also about some nonfriends, so we just ignore status change of contacts we don't have in list + MCONTACT hContact = ContactIDToHContact(id.as_string()); + if (!hContact) + continue; + + setWord(hContact, "Status", ID_STATUS_ONLINE); + } + + return EXIT_SUCCESS; +} + int FacebookProto::ParseUnreadThreads(std::string *data, std::vector< std::string >* threads) { std::string jsonData = data->substr(9); |