summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-04-21 07:15:50 +0000
committerRobert Pösel <robyer@seznam.cz>2016-04-21 07:15:50 +0000
commit9fb06fd3a3c18d3e27f68be92c7eab599cea8a14 (patch)
treebceba5b98ca4aae3aebb0f587f4c8b27613ab5a7
parent33e3d22f740af71112116977988f87d634d89617 (diff)
Facebook: Workaround for missing own avatar on some very rare occasions
Sometimes even Facebook doesn't show any picture at all! git-svn-id: http://svn.miranda-ng.org/main/trunk@16732 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/FacebookRM/src/communication.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 5e7d249048..8e77b71316 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -1146,15 +1146,21 @@ bool facebook_client::home()
// Final attempt to get avatar as on some pages is only link to photo page and not link to image itself
if (this->self_.image_url.empty()) {
- if (resp.data.find("/profile/picture/view/?profile_id=") != std::string::npos) {
- http::response resp2 = flap(REQUEST_PROFILE_PICTURE);
+ http::response resp2 = flap(REQUEST_PROFILE_PICTURE);
- // Get avatar (from mbasic version of photo page)
- this->self_.image_url = utils::text::html_entities_decode(utils::text::source_get_value(&resp2.data, 3, "id=\"root", "<img src=\"", "\""));
+ // Get avatar (from mbasic version of photo page)
+ this->self_.image_url = utils::text::html_entities_decode(utils::text::source_get_value(&resp2.data, 3, "id=\"root", "<img src=\"", "\""));
- // Get avatar (from touch version)
- if (this->self_.image_url.empty())
- this->self_.image_url = utils::text::html_entities_decode(utils::text::source_get_value(&resp2.data, 3, "id=\"root", "background-image: url(&quot;", "&quot;)"));
+ // Get avatar (from touch version)
+ if (this->self_.image_url.empty())
+ this->self_.image_url = utils::text::html_entities_decode(utils::text::source_get_value(&resp2.data, 3, "id=\"root", "background-image: url(&quot;", "&quot;)"));
+
+ // Sometimes even Facebook doesn't show any picture at all! So just ignore this error in that case...
+ if (this->self_.image_url.empty()) {
+ parent->debugLogA("!!! Empty avatar even from avatar page. Source code:\n%s", resp2.data.c_str());
+
+ // Set dumb avatar "url" (see how it works in CheckAvatarChange()) so we can't tell if/when the avatar changed, but it will be loaded at least once
+ this->self_.image_url = "/NO_AVATAR/";
}
}