diff options
author | Robert Pösel <robyer@seznam.cz> | 2016-09-04 14:05:03 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2016-09-04 14:05:03 +0000 |
commit | 4529adfa0ed7e69ffc3729144cd07c9a482f150f (patch) | |
tree | 1e79ce5a12e94b889b67cfcb964db9cce72bc497 /protocols | |
parent | 3dd0a1f40f3234973f41ed96d7d4890a560d95da (diff) |
Facebook: Fix sometimes wrongly identified users as friends
Also fixes related problem when it was showing "user was removed from server list" popup even when user was never your friend (due to problem above).
git-svn-id: http://svn.miranda-ng.org/main/trunk@17252 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 8 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 24 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 6 |
3 files changed, 22 insertions, 16 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 80ee795daa..720a842da8 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -32,19 +32,19 @@ void parseUser(const JSONNode &it, facebook_user *fbu) std::string thumbSrc = it["thumbSrc"].as_string(); std::string vanity = it["vanity"].as_string(); // username 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(); - //const JSONNode &uri = it["uri"); // profile url - //const JSONNode &is_friend = it["is_friend"); // e.g. "True" for type="friend", "False" for type="user", doesn't exist for type="page" + //const JSONNode &uri = it["uri"); // profile url if (type == "user" && (id.empty() || id == "0")) { // this user has deleted account or is just unavailable for us (e.g., ignore list) -> don't read dummy name and avatar and rather ignore that completely return; } - if (type == "friend") + if (type == "friend" && isFriend) fbu->type = CONTACT_FRIEND; - else if (type == "user") + else if (type == "user" || (type == "friend" && !isFriend)) fbu->type = CONTACT_NONE; else if (type == "page") fbu->type = CONTACT_PAGE; diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index a2b533cda9..c714c11419 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -138,20 +138,24 @@ void FacebookProto::ProcessFriendList(void*) fbu->deleted = true; } else { - // Contact was removed from "server-list", notify it + // Contact is not on "server-list", notify it was removed (if it was real friend before) - // Wasn't we already been notified about this contact? And was this real friend? - if (!getDword(hContact, FACEBOOK_KEY_DELETED, 0) && getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, 0) == CONTACT_FRIEND) { - setDword(hContact, FACEBOOK_KEY_DELETED, ::time(NULL)); + // Was this real friend before? + if (getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE) == CONTACT_FRIEND) { setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE); - // Notify it, if user wants to be notified - if (getByte(FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE, DEFAULT_EVENT_FRIENDSHIP_ENABLE)) { - std::string url = FACEBOOK_URL_PROFILE + std::string(id); - std::string contactname = getContactName(this, hContact, id); + // Wasn't we already been notified about this contact? + if (!getDword(hContact, FACEBOOK_KEY_DELETED, 0)) { + setDword(hContact, FACEBOOK_KEY_DELETED, ::time(NULL)); - ptrW szTitle(mir_utf8decodeW(contactname.c_str())); - NotifyEvent(szTitle, TranslateT("Contact is no longer on server-list."), hContact, EVENT_FRIENDSHIP, &url); + // Notify it, if user wants to be notified + if (getByte(FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE, DEFAULT_EVENT_FRIENDSHIP_ENABLE)) { + std::string url = FACEBOOK_URL_PROFILE + std::string(id); + std::string contactname = getContactName(this, hContact, id); + + ptrW szTitle(mir_utf8decodeW(contactname.c_str())); + NotifyEvent(szTitle, TranslateT("Contact is no longer on server-list."), hContact, EVENT_FRIENDSHIP, &url); + } } } } diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 02bd8e8d3d..291911d345 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -364,8 +364,10 @@ int FacebookProto::GetInfo(MCONTACT hContact, int) setByte(hContact, "Gender", fbu.gender); } - if (fbu.type == CONTACT_PAGE || fbu.type == CONTACT_FRIEND) { - if (getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE) != fbu.type) { + int oldType = getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE); + // From server we won't get request/approve types, only none, so we don't want to overwrite and lost it in that case + if (fbu.type != CONTACT_NONE || (oldType != CONTACT_REQUEST && oldType != CONTACT_APPROVE)) { + if (oldType != fbu.type) { setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, fbu.type); } } |