summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-03-05 18:45:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-03-05 18:45:04 +0300
commita9a1da437a9388a34c35a62992130480d8e5986c (patch)
tree1bf92912d1abb8c4930da9bcc1c0a09a2da69da8 /protocols/FacebookRM/src
parenta9dcf740f4290fa9e6b0c957adb09f954500016e (diff)
fixes #1875 (Facebook fails to log in)
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/communication.cpp52
1 files changed, 25 insertions, 27 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 39f4a1866d..d865b85c06 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -797,42 +797,40 @@ bool facebook_client::reconnect()
// Request reconnect
http::response resp = sendRequest(reconnectRequest());
+ if (resp.code != HTTP_CODE_OK)
+ return handle_error("reconnect", FORCE_DISCONNECT);
- switch (resp.code) {
- case HTTP_CODE_OK:
- {
- this->chat_channel_ = utils::text::source_get_value(&resp.data, 2, "\"user_channel\":\"", "\"");
- parent->debugLogA(" Got self channel: %s", this->chat_channel_.c_str());
-
- this->chat_channel_partition_ = utils::text::source_get_value2(&resp.data, "\"partition\":", ",}");
- parent->debugLogA(" Got self channel partition: %s", this->chat_channel_partition_.c_str());
+ std::string redir = utils::text::source_get_value(&resp.data, 2, "\"redirect\":\"", "\"");
+ if (!redir.empty()) {
+ parent->debugLogA("Redirecting to %s", redir.c_str());
- this->chat_channel_host_ = utils::text::source_get_value(&resp.data, 2, "\"host\":\"", "\"");
- parent->debugLogA(" Got self channel host: %s", this->chat_channel_host_.c_str());
+ auto *p = new HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR);
+ p->m_szUrl = redir.c_str();
+ resp = sendRequest(p);
+ if (resp.code != HTTP_CODE_OK)
+ return handle_error("reconnect", FORCE_DISCONNECT);
+ }
- this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}");
- parent->debugLogA(" Got self sequence number: %s", this->chat_sequence_num_.c_str());
+ this->chat_channel_ = utils::text::source_get_value(&resp.data, 2, "\"user_channel\":\"", "\"");
+ parent->debugLogA(" Got self channel: %s", this->chat_channel_.c_str());
- this->chat_conn_num_ = utils::text::source_get_value2(&resp.data, "\"max_conn\":", ",}");
- parent->debugLogA(" Got self max_conn: %s", this->chat_conn_num_.c_str());
+ this->chat_channel_partition_ = utils::text::source_get_value2(&resp.data, "\"partition\":", ",}");
+ parent->debugLogA(" Got self channel partition: %s", this->chat_channel_partition_.c_str());
- this->chat_sticky_num_ = utils::text::source_get_value(&resp.data, 2, "\"sticky_token\":\"", "\"");
- parent->debugLogA(" Got self sticky_token: %s", this->chat_sticky_num_.c_str());
+ this->chat_channel_host_ = utils::text::source_get_value(&resp.data, 2, "\"host\":\"", "\"");
+ parent->debugLogA(" Got self channel host: %s", this->chat_channel_host_.c_str());
- //std::string retry_interval = utils::text::source_get_value2(&resp.data, "\"retry_interval\":", ",}");
- //parent->debugLogA(" Got self retry_interval: %s", retry_interval.c_str());
+ this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}");
+ parent->debugLogA(" Got self sequence number: %s", this->chat_sequence_num_.c_str());
- //std::string visibility = utils::text::source_get_value2(&resp.data, "\"visibility\":", ",}");
- //parent->debugLogA(" Got self visibility: %s", visibility.c_str());
+ this->chat_conn_num_ = utils::text::source_get_value2(&resp.data, "\"max_conn\":", ",}");
+ parent->debugLogA(" Got self max_conn: %s", this->chat_conn_num_.c_str());
- // Send activity_ping after each reconnect
- activity_ping();
- }
- return handle_success("reconnect");
+ this->chat_sticky_num_ = utils::text::source_get_value(&resp.data, 2, "\"sticky_token\":\"", "\"");
+ parent->debugLogA(" Got self sticky_token: %s", this->chat_sticky_num_.c_str());
- default:
- return handle_error("reconnect", FORCE_DISCONNECT);
- }
+ activity_ping();
+ return handle_success("reconnect");
}
bool facebook_client::channel()