From 25ea4914a0b396fd603cd5cc6ef804271563f485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Sun, 4 Dec 2016 14:49:12 +0100 Subject: Facebook: Load only friends at login Because of some change on Facebook side it started sending not only friends, but also other people we talked in some time in history. This commit ignores them and won't load them at login. --- protocols/FacebookRM/src/json.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index bf1ed05a38..bb41cd415b 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -34,6 +34,7 @@ void parseUser(const JSONNode &it, facebook_user *fbu) std::string type = it["type"].as_string(); // "friend", "page", "user" (friend with disabled account or not friend) bool isFriend = it["is_friend"].as_bool(); // e.g. "True" or "False" for type="friend" (I don't know why), "False" for type="user", doesn't exist for type="page" int gender = it["gender"].as_int(); + // bool isMessengerContact = it["is_nonfriend_messenger_contact"].as_bool(); // "True" or "False", but we don't care as "is_friend" and "type" are enough for us //const JSONNode &uri = it["uri"); // profile url @@ -179,6 +180,12 @@ int facebook_json_parser::parse_friends(std::string *data, std::map< std::string facebook_user *fbu = new facebook_user(); parseUser(*it, fbu); + // Facebook now sends also other types of contacts, which we do not want here + if (fbu->type != CONTACT_FRIEND) { + delete fbu; + continue; + } + friends->insert(std::make_pair(fbu->user_id, fbu)); } @@ -772,9 +779,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vectorContactIDToHContact(id); if (!hContact) { - // FIXME: What to do, when we don't have this contact? What does it mean? - // fbu->type = CONTACT_FRIEND; // add this contact as a friend? - // fbu->handle = AddToContactList(fbu); + // Facebook now sends info also about some nonfriends, so we just ignore status change of contacts we don't have in list continue; } @@ -855,9 +860,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vectorContactIDToHContact(id); if (!hContact) { - // FIXME: What to do, when we don't have this contact? What does it mean? - // fbu->type = CONTACT_FRIEND; // add this contact as a friend? - // fbu->handle = AddToContactList(fbu); + // Facebook now sends info also about some nonfriends, so we just ignore status change of contacts we don't have in list continue; } -- cgit v1.2.3