diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/src/connection.cpp | 16 | ||||
-rw-r--r-- | protocols/Discord/src/http.cpp | 8 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/Discord/src/server.cpp | 5 |
4 files changed, 19 insertions, 11 deletions
diff --git a/protocols/Discord/src/connection.cpp b/protocols/Discord/src/connection.cpp index d3c44b2d9a..969e85fb05 100644 --- a/protocols/Discord/src/connection.cpp +++ b/protocols/Discord/src/connection.cpp @@ -33,8 +33,10 @@ void CDiscordProto::ExecuteRequest(AsyncHttpRequest *pReq) } } - pReq->flags |= NLHRF_PERSISTENT; - pReq->nlc = m_hAPIConnection; + if (pReq->m_bMainSite) { + pReq->flags |= NLHRF_PERSISTENT; + pReq->nlc = m_hAPIConnection; + } debugLogA("Executing request #%d:\n%s", pReq->m_iReqNum, pReq->szUrl); NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)pReq); @@ -49,11 +51,11 @@ void CDiscordProto::ExecuteRequest(AsyncHttpRequest *pReq) else { debugLogA("Request %d failed", pReq->m_iReqNum); - if (IsStatusConnecting(m_iStatus)) - ConnectionFailed(LOGINERR_NONETWORK); - else - ShutdownSession(); - m_hAPIConnection = NULL; + if (pReq->m_bMainSite) { + if (IsStatusConnecting(m_iStatus)) + ConnectionFailed(LOGINERR_NONETWORK); + m_hAPIConnection = NULL; + } } delete pReq; } diff --git a/protocols/Discord/src/http.cpp b/protocols/Discord/src/http.cpp index 90393ec6ef..a9136c5552 100644 --- a/protocols/Discord/src/http.cpp +++ b/protocols/Discord/src/http.cpp @@ -43,10 +43,14 @@ AsyncHttpRequest::AsyncHttpRequest(CDiscordProto *ppro, int iRequestType, LPCSTR cbSize = sizeof(NETLIBHTTPREQUEST); if (*_url == '/') { // relative url leads to a site - m_szUrl = "https://discordapp.com/api"; + m_szUrl = "https://discordapp.com/api/v6"; m_szUrl += _url; + m_bMainSite = true; + } + else { + m_szUrl = _url; + m_bMainSite = false; } - else m_szUrl = _url; flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_SSL; if (ppro->m_szAccessToken != NULL) { diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index f9a0c99481..15a6a9eeeb 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -17,6 +17,7 @@ struct AsyncHttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject CMStringA m_szParam; HttpCallback m_pCallback; int m_iErrorCode, m_iReqNum; + bool m_bMainSite; void *pUserInfo; }; diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index 270127a904..858be58c55 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -274,8 +274,9 @@ void CDiscordProto::OnReceiveMessageAck(NETLIBHTTPREQUEST *pReply, AsyncHttpRequ CMStringW wszToken(root["token"].as_mstring()); if (!wszToken.IsEmpty()) { JSONNode props; props.set_name("properties"); - root << CHAR_PARAM("event", "ack_messages") << props; - Push(new AsyncHttpRequest(this, REQUEST_POST, "/track", NULL, &root)); + JSONNode reply; reply << props; + reply << CHAR_PARAM("event", "ack_messages") << WCHAR_PARAM("token", root["token"].as_mstring()); + Push(new AsyncHttpRequest(this, REQUEST_POST, "/track", NULL, &reply)); } } |