From 9406569f424b79ff8186f7608cb479e2dbf3a420 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 28 Dec 2019 22:36:14 +0300 Subject: fixes #2160 (Facebook: deleted session doesn't empty invalid security token) --- protocols/Facebook/src/proto.h | 2 +- protocols/Facebook/src/server.cpp | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'protocols/Facebook') diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h index be40348793..b25cd31d5c 100644 --- a/protocols/Facebook/src/proto.h +++ b/protocols/Facebook/src/proto.h @@ -428,7 +428,7 @@ class FacebookProto : public PROTO void OnLoggedOut(); bool RefreshToken(); - bool RefreshContacts(); + int RefreshContacts(); void __cdecl SendMessageAckThread(void *); void __cdecl ServerThread(void *); diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index 000e15684a..6cfd025ea4 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -89,15 +89,15 @@ void FacebookProto::OnLoggedOut() m_bOnline = false; } -bool FacebookProto::RefreshContacts() +int FacebookProto::RefreshContacts() { auto *pReq = CreateRequestGQL(FB_API_QUERY_CONTACTS); pReq << CHAR_PARAM("query_params", "{\"0\":[\"user\"],\"1\":\"" FB_API_CONTACTS_COUNT "\"}"); pReq->CalcSig(); JsonReply reply(ExecuteRequest(pReq)); - if (reply.error()) - return false; + if (int iErrorCode = reply.error()) + return iErrorCode; // unknown error bool bNeedUpdate = false; @@ -154,7 +154,7 @@ bool FacebookProto::RefreshContacts() if (bNeedUpdate) ForkThread(&FacebookProto::AvatarsUpdate); - return true; + return 0; } bool FacebookProto::RefreshToken() @@ -182,8 +182,8 @@ bool FacebookProto::RefreshToken() void FacebookProto::ServerThread(void *) { +LBL_Begin: m_szAuthToken = getMStringA(DBKEY_TOKEN); - if (m_szAuthToken.IsEmpty()) { if (!RefreshToken()) { ConnectionFailed(); @@ -191,7 +191,13 @@ void FacebookProto::ServerThread(void *) } } - if (!RefreshContacts()) { + int iErrorCode = RefreshContacts(); + if (iErrorCode != 0) { + if (iErrorCode == 401) { + delSetting(DBKEY_TOKEN); + goto LBL_Begin; + } + ConnectionFailed(); return; } -- cgit v1.2.3