diff options
author | George Hazan <ghazan@miranda.im> | 2017-01-10 17:35:39 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-01-10 17:35:39 +0300 |
commit | 4bab8b2f2fc446ff23b2c94aa1c7de9947db0ed4 (patch) | |
tree | b9f592ad71d207f29f57714ed13b238cd2411652 /protocols | |
parent | 77cccf9d4b13d9fad437eaf6361cec016a4ce27c (diff) |
more thorough fix for duplicate messages
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/src/server.cpp | 12 | ||||
-rw-r--r-- | protocols/Discord/src/version.h | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index a8a44b500a..82b6113dfc 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -243,11 +243,21 @@ void CDiscordProto::OnReceiveGuilds(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest* void CDiscordProto::OnReceiveMessageAck(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) { + MCONTACT hContact = (MCONTACT)pReq->pUserInfo; + bool bSucceeded = true; if (pReply->resultCode != 200 && pReply->resultCode != 204) bSucceeded = false; - ProtoBroadcastAck((MCONTACT)pReq->pUserInfo, ACKTYPE_MESSAGE, bSucceeded ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)pReq->m_iReqNum, 0); + JSONNode root = JSONNode::parse(pReply->pData); + if (root) { + SnowFlake newLastId = _wtoi64(root["id"].as_mstring()); + SnowFlake oldLastId = getId(hContact, DB_KEY_LASTMSGID); // as stored in a database + if (oldLastId < newLastId) + setId(hContact, DB_KEY_LASTMSGID, newLastId); + } + + ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, bSucceeded ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)pReq->m_iReqNum, 0); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Discord/src/version.h b/protocols/Discord/src/version.h index d7b213ad39..283aed187b 100644 --- a/protocols/Discord/src/version.h +++ b/protocols/Discord/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 #include <stdver.h> |