diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-12-22 19:00:27 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-12-22 19:00:27 +0000 |
commit | ac8bed8f05473bf773b9729d5acef4b49dde3682 (patch) | |
tree | e4acef721054ef0fa89676061147e2bba9b6baf1 /protocols | |
parent | f5e9122078e308f4b9dfa70b4f160056fae95c19 (diff) |
Steam: Various fixes to loading offline messages
git-svn-id: http://svn.miranda-ng.org/main/trunk@15933 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Steam/src/api/history.h | 3 | ||||
-rw-r--r-- | protocols/Steam/src/steam_history.cpp | 24 | ||||
-rw-r--r-- | protocols/Steam/src/steam_login.cpp | 6 | ||||
-rw-r--r-- | protocols/Steam/src/steam_messages.cpp | 4 | ||||
-rw-r--r-- | protocols/Steam/src/steam_polling.cpp | 8 |
5 files changed, 24 insertions, 21 deletions
diff --git a/protocols/Steam/src/api/history.h b/protocols/Steam/src/api/history.h index fc3c7c8a6b..86e29a6da2 100644 --- a/protocols/Steam/src/api/history.h +++ b/protocols/Steam/src/api/history.h @@ -20,7 +20,8 @@ public: AddParameter("access_token", token); AddParameter("steamid1", steamId); AddParameter("steamid2", who); - AddParameter("rtime32_start_time=%d", since); + // Steam somehow doesn't respect too precise start time parameter, so we better request older time and then do own filtering again + AddParameter("rtime32_start_time=%d", since - 1500); } }; diff --git a/protocols/Steam/src/steam_history.cpp b/protocols/Steam/src/steam_history.cpp index d2fe8b4d50..75e40a5674 100644 --- a/protocols/Steam/src/steam_history.cpp +++ b/protocols/Steam/src/steam_history.cpp @@ -2,6 +2,10 @@ void CSteamProto::OnGotConversations(const HttpResponse *response) { + // Don't load any messages when we don't have lastMessageTS, as it may cause duplicates + if (m_lastMessageTS <= 0) + return; + if (!ResponseHttpOk(response)) return; @@ -10,18 +14,6 @@ void CSteamProto::OnGotConversations(const HttpResponse *response) return; JSONNode *node = json_get(root, "response"); - - if (m_lastMessageTS <= 0) - { - // Remember and save actual timestamp (as it is first we've got) - JSONNode *timestampNode = json_get(node, "timestamp"); - m_lastMessageTS = _ttoi64(ptrT(json_as_string(timestampNode))); - setDword("LastMessageTS", m_lastMessageTS); - - // And don't load any messages as it may cause duplicates - return; - } - JSONNode *sessions = json_get(node, "message_sessions"); JSONNode *nsessions = json_as_array(sessions); @@ -96,6 +88,10 @@ void CSteamProto::OnGotHistoryMessages(const HttpResponse *response, void *arg) node = json_get(message, "timestamp"); time_t timestamp = _ttoi64(ptrT(json_as_string(node))); + // Ignore already existing messages + if (timestamp <= m_lastMessageTS) + continue; + PROTORECVEVENT recv = { 0 }; recv.timestamp = timestamp; recv.szMessage = szMessage; @@ -111,10 +107,6 @@ void CSteamProto::OnGotHistoryMessages(const HttpResponse *response, void *arg) recv.flags = PREF_SENT; Proto_RecvMessage(hContact, &recv); } - - // Update last message timestamp - if (timestamp > getDword("LastMessageTS", 0)) - setDword("LastMessageTS", timestamp); } json_delete(nmessages); diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp index f2d06b208d..8a4e5c8255 100644 --- a/protocols/Steam/src/steam_login.cpp +++ b/protocols/Steam/src/steam_login.cpp @@ -354,6 +354,12 @@ void CSteamProto::OnLoggedOn(const HttpResponse *response) node = json_get(root, "message"); setDword("MessageID", json_as_int(node)); + + if (m_lastMessageTS <= 0) { + node = json_get(root, "utc_timestamp"); + time_t timestamp = _ttoi64(ptrT(json_as_string(node))); + setDword("LastMessageTS", timestamp); + } // load contact list ptrA token(getStringA("TokenSecret")); diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index c2172bb380..56cb5f2f62 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -51,7 +51,11 @@ void CSteamProto::OnMessageSent(const HttpResponse *response, void *arg) node = json_get(root, "utc_timestamp");
if (node)
+ {
timestamp = atol(ptrA(mir_t2a(ptrT(json_as_string(node)))));
+ if (timestamp > getDword("LastMessageTS", 0))
+ setDword("LastMessageTS", timestamp);
+ }
}
if (mir_tstrcmpi(error, _T("OK")) != 0)
diff --git a/protocols/Steam/src/steam_polling.cpp b/protocols/Steam/src/steam_polling.cpp index eadade3d99..bbc05e1451 100644 --- a/protocols/Steam/src/steam_polling.cpp +++ b/protocols/Steam/src/steam_polling.cpp @@ -216,10 +216,10 @@ void CSteamProto::PollingThread(void*) if (!lstrcmpi(error, _T("OK"))) { // Remember last message timestamp - node = json_get(root, "timestamp"); - time_t lastMessageTS = _ttoi64(ptrT(json_as_string(node))); - if (lastMessageTS > getDword("LastMessageTS", 0)) - setDword("LastMessageTS", lastMessageTS); + node = json_get(root, "utc_timestamp"); + time_t timestamp = _ttoi64(ptrT(json_as_string(node))); + if (timestamp > getDword("LastMessageTS", 0)) + setDword("LastMessageTS", timestamp); node = json_get(root, "messagelast"); messageId = json_as_int(node); |