diff options
author | George Hazan <ghazan@miranda.im> | 2017-01-18 23:09:41 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-01-18 23:09:41 +0300 |
commit | 4e993e88b4edaa760f854eacbe02d4c8896a2440 (patch) | |
tree | 98f2e85c6e34c46aee0c08beac12a59e88dc820b /protocols/Discord/src/proto.cpp | |
parent | 912f1514c3488014ac0174bd533f4bfeb1de0a44 (diff) |
Discord:
- fix for reading our own messages typed in another place;
- version bump
Diffstat (limited to 'protocols/Discord/src/proto.cpp')
-rw-r--r-- | protocols/Discord/src/proto.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index 814ca19c0d..f161d27e49 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -17,6 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" +static int compareMessages(const SnowFlake *p1, const SnowFlake *p2) +{ + return *p1 - *p2; +} + static int compareRequests(const AsyncHttpRequest *p1, const AsyncHttpRequest *p2) { return p1->m_iReqNum - p2->m_iReqNum; @@ -34,6 +39,7 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) : m_wszDefaultGroup(this, DB_KEY_GROUP, DB_KEYVAL_GROUP), m_wszEmail(this, DB_KEY_EMAIL, L""), arMarkReadQueue(1, compareUsers), + arOwnMessages(1, compareMessages), arUsers(50, compareUsers) { // Services @@ -345,7 +351,9 @@ int CDiscordProto::SendMsg(MCONTACT hContact, int /*flags*/, const char *pszSrc) return 0; CMStringA szUrl(FORMAT, "/channels/%lld/messages", pUser->channelId); - JSONNode body; body << WCHAR_PARAM("content", wszText); + SnowFlake nonce; Utils_GetRandom(&nonce, sizeof(nonce)); + JSONNode body; body << WCHAR_PARAM("content", wszText) << INT64_PARAM("nonce", nonce); + arOwnMessages.insert(new SnowFlake(nonce)); AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, szUrl, &CDiscordProto::OnReceiveMessage, &body); pReq->pUserInfo = (void*)hContact; Push(pReq); |