From 5dc9ff65b453efdcbe2218720307fae52b5d6e90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Robert=20P=C3=B6sel?= <robyer@seznam.cz>
Date: Sat, 16 Jul 2016 13:38:04 +0000
Subject: Facebook: Improve loading user info about "facebook pages" contacts

git-svn-id: http://svn.miranda-ng.org/main/trunk@17098 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 protocols/FacebookRM/src/json.cpp | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

(limited to 'protocols')

diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 702cf18060..bc79b6b8b6 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -26,21 +26,21 @@ void parseUser(const JSONNode &it, facebook_user *fbu)
 {
 	fbu->user_id = it.name();
 
-	std::string id = it["id"].as_string();
-	if (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;
-	}
-
+	std::string id = it["id"].as_string(); // same as element's name, but doesn't exists for "page" type
 	std::string alternateName = it["alternateName"].as_string(); // nickname
 	std::string name = it["name"].as_string();
 	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)
 	int gender = it["gender"].as_int();
 
 	//const JSONNode &uri = it["uri"); // profile url
-	//const JSONNode &is_friend = it["is_friend"); // e.g. "True"
-	//const JSONNode &type = it["type"); // e.g. "friend" (classic contact) or "user" (disabled/deleted account)
+	//const JSONNode &is_friend = it["is_friend"); // e.g. "True" for type="friend", "False" for type="user", doesn't exist for type="page"
+
+	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 (!name.empty())
 		fbu->real_name = utils::text::slashu_to_utf8(name);
@@ -59,7 +59,8 @@ void parseUser(const JSONNode &it, facebook_user *fbu)
 		case 2: // male
 			fbu->gender = 77;
 			break;
-			// case 7: not available female?
+		// case 7: // not available female?
+		// case 11: // page
 		}
 	}
 }
-- 
cgit v1.2.3