diff options
author | George Hazan <ghazan@miranda.im> | 2017-01-30 19:37:59 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-01-30 19:37:59 +0300 |
commit | 02b8906821e7260ad343b14715ef0d1cdd500bb8 (patch) | |
tree | da2dac177921e25f2340f01930221ad70ee35b9b /protocols/Discord/src | |
parent | 476f5f44c4a1aa2e6bb1cd9aa915b633a1e23099 (diff) |
fix for the order of history messages
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r-- | protocols/Discord/src/server.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index b87bc4eaf8..be38b7ffac 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -47,6 +47,11 @@ void CDiscordProto::RetrieveHistory(MCONTACT hContact, CDiscordHitoryOp iOp, Sno Push(pReq); } +static int compareMsgHistory(const JSONNode *p1, const JSONNode *p2) +{ + return wcscmp((*p1)["id"].as_mstring(), (*p2)["id"].as_mstring()); +} + void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) { CDiscordUser *pUser = (CDiscordUser*)pReq->pUserInfo; @@ -65,9 +70,15 @@ void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest SnowFlake lastId = getId(pUser->hContact, DB_KEY_LASTMSGID); // as stored in a database + LIST<JSONNode> arNodes(10, compareMsgHistory); int iNumMessages = 0; for (auto it = root.begin(); it != root.end(); ++it, ++iNumMessages) { JSONNode &p = *it; + arNodes.insert(&p); + } + + for (int i = 0; i < arNodes.getCount(); i++) { + JSONNode &p = *arNodes[i]; SnowFlake authorid = _wtoi64(p["author"]["id"].as_mstring()); if (authorid == m_ownId) |