summaryrefslogtreecommitdiff
path: root/protocols/Facebook
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-12-28 22:36:14 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-12-28 22:36:14 +0300
commit9406569f424b79ff8186f7608cb479e2dbf3a420 (patch)
tree432eb948490745dcb2881a1358f3c6e3808e9725 /protocols/Facebook
parentf4c0a80048dd2ed919ed56cdb856d27f1d0685e4 (diff)
fixes #2160 (Facebook: deleted session doesn't empty invalid security token)
Diffstat (limited to 'protocols/Facebook')
-rw-r--r--protocols/Facebook/src/proto.h2
-rw-r--r--protocols/Facebook/src/server.cpp18
2 files changed, 13 insertions, 7 deletions
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<FacebookProto>
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;
}