summaryrefslogtreecommitdiff
path: root/protocols/Discord/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r--protocols/Discord/src/gateway.cpp2
-rw-r--r--protocols/Discord/src/proto.cpp4
-rw-r--r--protocols/Discord/src/stdafx.h13
-rw-r--r--protocols/Discord/src/utils.cpp9
4 files changed, 25 insertions, 3 deletions
diff --git a/protocols/Discord/src/gateway.cpp b/protocols/Discord/src/gateway.cpp
index 6b5e320904..fe3bf8e800 100644
--- a/protocols/Discord/src/gateway.cpp
+++ b/protocols/Discord/src/gateway.cpp
@@ -259,7 +259,7 @@ void CDiscordProto::GatewaySendIdentify()
void CDiscordProto::GatewaySendGuildInfo(SnowFlake id)
{
JSONNode payload(JSON_ARRAY); payload.set_name("d");
- payload << INT64_PARAM("", id);
+ payload << SINT64_PARAM("", id);
JSONNode root;
root << INT_PARAM("op", 12) << payload;
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index 0ab49eb03c..cda830c3d5 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -409,7 +409,7 @@ int CDiscordProto::SendMsg(MCONTACT hContact, int /*flags*/, const char *pszSrc)
// no channel - we need to create one
if (pUser->channelId == 0) {
- JSONNode list(JSON_ARRAY); list.set_name("recipients"); list << INT64_PARAM("", pUser->id);
+ JSONNode list(JSON_ARRAY); list.set_name("recipients"); list << SINT64_PARAM("", pUser->id);
JSONNode body; body << list;
CMStringA szUrl(FORMAT, "/users/%lld/channels", m_ownId);
@@ -424,7 +424,7 @@ int CDiscordProto::SendMsg(MCONTACT hContact, int /*flags*/, const char *pszSrc)
// we generate a random 64-bit integer and pass it to the server
// to distinguish our own messages from these generated by another clients
SnowFlake nonce; Utils_GetRandom(&nonce, sizeof(nonce)); nonce = abs(nonce);
- JSONNode body; body << WCHAR_PARAM("content", wszText) << INT64_PARAM("nonce", nonce);
+ JSONNode body; body << WCHAR_PARAM("content", wszText) << SINT64_PARAM("nonce", nonce);
CMStringA szUrl(FORMAT, "/channels/%lld/messages", pUser->channelId);
AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, szUrl, nullptr, &body);
diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h
index 568f5db2ed..4d9ba98487 100644
--- a/protocols/Discord/src/stdafx.h
+++ b/protocols/Discord/src/stdafx.h
@@ -63,6 +63,19 @@ extern IconItem g_iconList[];
#include "version.h"
#include "proto.h"
+struct SINT64_PARAM : public PARAM
+{
+ int64_t iValue;
+ __forceinline SINT64_PARAM(const char *_name, int64_t _value) :
+ PARAM(_name), iValue(_value)
+ {
+ }
+};
+
+JSONNode& operator<<(JSONNode &json, const SINT64_PARAM &param);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void BuildStatusList(const CDiscordGuild *pGuild, SESSION_INFO *si);
SnowFlake getId(const JSONNode &pNode);
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp
index d2b8f701d3..0a96809354 100644
--- a/protocols/Discord/src/utils.cpp
+++ b/protocols/Discord/src/utils.cpp
@@ -32,6 +32,15 @@ int StrToStatus(const CMStringW &str)
/////////////////////////////////////////////////////////////////////////////////////////
+JSONNode& operator<<(JSONNode &json, const SINT64_PARAM &param)
+{
+ char str[40];
+ _i64toa(param.iValue, str, 10);
+ return json << CHAR_PARAM(param.szName, str);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
time_t StringToDate(const CMStringW &str)
{
struct tm T = { 0 };