diff options
author | Robert Pösel <robyer@seznam.cz> | 2017-01-22 21:43:45 +0100 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2017-01-22 21:43:45 +0100 |
commit | ea70f07b4e6de61e75b4da821e7c93c6f3abdeea (patch) | |
tree | 9e1aae43ce86d4967cef563fd987771d8ac0f1fd /protocols | |
parent | 4b3ab972d3109f4014746fc8b1ea5b443697861c (diff) |
Facebook: Support searching by entering profile URL (into ID field)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 7551c71077..600dc5a952 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -1286,9 +1286,19 @@ void FacebookProto::SearchIdAckThread(void *targ) { facy.handle_entry("searchIdAckThread"); - std::string search = utils::url::encode(T2Utf((wchar_t*)targ).str()); + std::string search = T2Utf((wchar_t*)targ).str(); + if (search.find(FACEBOOK_SERVER_DOMAIN "/") != std::string::npos) { + // User entered URL, let's extract id/username from it + std::string id = utils::text::source_get_value2(&search, "/profile.php?id=", "&#", true); + if (id.empty()) { + // This link probably contains username (if user entered proper profile url) + id = utils::text::source_get_value2(&search, FACEBOOK_SERVER_DOMAIN "/", "?&#", true); + } + search = id; + } + search = utils::url::encode(search); - if (!isOffline()) + if (!isOffline() && !search.empty()) { http::response resp = facy.sendRequest(new ProfileRequest(facy.mbasicWorks, search.c_str())); |