diff options
Diffstat (limited to 'protocols/Discord')
-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> |