summaryrefslogtreecommitdiff
path: root/protocols/Facebook/src/server.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-05-01 14:02:53 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-05-01 14:02:58 +0300
commit23bccd1f28fa196f779dca3daca1fe7ba54ee4d1 (patch)
treeada513b1f4154154f403aadf272bd1df3a5114b0 /protocols/Facebook/src/server.cpp
parent099f41b05c066c2c39d10b4b6b18280ef5f2254f (diff)
fixes #2318 (Facebook: stopped getting new message notifications)
Diffstat (limited to 'protocols/Facebook/src/server.cpp')
-rw-r--r--protocols/Facebook/src/server.cpp44
1 files changed, 27 insertions, 17 deletions
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();