diff options
-rw-r--r-- | protocols/Facebook/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/Facebook/src/server.cpp | 44 | ||||
-rw-r--r-- | protocols/Facebook/src/version.h | 2 |
3 files changed, 29 insertions, 18 deletions
diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h index ee81e02053..1df80c6e4d 100644 --- a/protocols/Facebook/src/proto.h +++ b/protocols/Facebook/src/proto.h @@ -472,6 +472,7 @@ class FacebookProto : public PROTO<FacebookProto> void OnLoggedIn(); void OnLoggedOut(); + bool RefreshSid(); bool RefreshToken(); FacebookUser* RefreshThread(JSONNode& n); FacebookUser* RefreshThread(CMStringW& wszId); diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index 4fb5c0608c..4106e4781c 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -55,21 +55,10 @@ void FacebookProto::OnLoggedIn() // if sequence is not initialized, request SID from the server if (m_sid == 0) { - auto *pReq = CreateRequestGQL(FB_API_QUERY_SEQ_ID); - pReq << CHAR_PARAM("query_params", "{\"1\":\"0\"}"); - pReq->CalcSig(); - - JsonReply reply(ExecuteRequest(pReq)); - if (reply.error()) { + if (!RefreshSid()) { ConnectionFailed(); return; } - - auto &n = reply.data()["viewer"]["message_threads"]; - CMStringW wszSid(n["sync_sequence_id"].as_mstring()); - setWString(DBKEY_SID, wszSid); - m_sid = _wtoi64(wszSid); - m_iUnread = n["unread_count"].as_int(); } // point of no return; @@ -199,6 +188,24 @@ int FacebookProto::RefreshContacts() return 0; } +bool FacebookProto::RefreshSid() +{ + auto *pReq = CreateRequestGQL(FB_API_QUERY_SEQ_ID); + pReq << CHAR_PARAM("query_params", "{\"1\":\"0\"}"); + pReq->CalcSig(); + + JsonReply reply(ExecuteRequest(pReq)); + if (reply.error()) + return false; + + auto &n = reply.data()["viewer"]["message_threads"]; + CMStringW wszSid(n["sync_sequence_id"].as_mstring()); + setWString(DBKEY_SID, wszSid); + m_sid = _wtoi64(wszSid); + m_iUnread = n["unread_count"].as_int(); + return true; +} + FacebookUser* FacebookProto::RefreshThread(JSONNode& n) { if (!n["is_group_thread"].as_bool()) return nullptr; @@ -563,14 +570,17 @@ void FacebookProto::OnPublishMessage(FbThriftReader &rdr) CMStringA errorCode = root["errorCode"].as_mstring(); if (!errorCode.IsEmpty()) { - if (!m_QueueCreated && (errorCode == "ERROR_QUEUE_OVERFLOW" || errorCode == "ERROR_QUEUE_NOT_FOUND" || errorCode == "ERROR_QUEUE_LOST" )) { + if (!m_QueueCreated && (errorCode == "ERROR_QUEUE_OVERFLOW" || errorCode == "ERROR_QUEUE_NOT_FOUND" || errorCode == "ERROR_QUEUE_LOST")) { m_QueueCreated = true; // prevent queue creation request from being sent twice - m_szSyncToken.Empty(); - delSetting(DBKEY_SYNC_TOKEN); + m_sid = 0; + delSetting(DBKEY_SID); + if (!RefreshSid()) { + ConnectionFailed(); + return; + } + MqttQueueConnect(); } - - return; } CMStringW str = root["lastIssuedSeqId"].as_mstring(); diff --git a/protocols/Facebook/src/version.h b/protocols/Facebook/src/version.h index 45bbcaf19f..8a4aff26a6 100644 --- a/protocols/Facebook/src/version.h +++ b/protocols/Facebook/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 5 +#define __BUILD_NUM 6 #include <stdver.h> |