diff options
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 97c9c21477..864c37ab90 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -72,6 +72,8 @@ int facebook_json_parser::parse_buddy_list(std::string *data, List::List< facebo current->client = CLIENT_MOBILE; } + time_t now = ::time(NULL); + // Find now available contacts const JSONNode &nowAvailable = list["nowAvailableList"]; for (auto it = nowAvailable.begin(); it != nowAvailable.end(); ++it) { @@ -98,6 +100,12 @@ int facebook_json_parser::parse_buddy_list(std::string *data, List::List< facebo current->status_id = (current->client == CLIENT_MOBILE || current->client == CLIENT_MESSENGER) ? ID_STATUS_ONTHEPHONE : ID_STATUS_ONLINE; + // Set contacts that were last active more than 1 minute ago as away + if (current->status_id == ID_STATUS_ONLINE && current->last_active > 0 && (now - current->last_active) > 60) { + current->status_id = ID_STATUS_AWAY; + current->idle = true; + } + // Facebook is not sending this info anymore, it should be removed const JSONNode &p = (*it)["p"]; if (p) { @@ -729,7 +737,10 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector< facebo bool isVisible = visibility && visibility.as_bool(); proto->debugLogA(" Requested chat switch to %s", isVisible ? "Online" : "Offline"); - proto->SetStatus(isVisible ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE); + + // If actual status is not what server says, change it (handle also local away status, which means online) + if (isVisible != (proto->m_iStatus != ID_STATUS_INVISIBLE)) + proto->SetStatus(isVisible ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE); } } else if (t == "buddylist_overlay") { |