summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Discord/src/http.cpp2
-rw-r--r--protocols/Discord/src/proto.cpp3
-rw-r--r--protocols/Discord/src/proto.h1
-rw-r--r--protocols/Discord/src/server.cpp27
4 files changed, 17 insertions, 16 deletions
diff --git a/protocols/Discord/src/http.cpp b/protocols/Discord/src/http.cpp
index b349eac36b..c5d5e1e0c0 100644
--- a/protocols/Discord/src/http.cpp
+++ b/protocols/Discord/src/http.cpp
@@ -41,7 +41,7 @@ static LONG g_reqNum = 0;
AsyncHttpRequest::AsyncHttpRequest(CDiscordProto *ppro, int iRequestType, LPCSTR _url, MTHttpRequestHandler pFunc, JSONNode *pRoot)
{
if (*_url == '/') { // relative url leads to a site
- m_szUrl = "https://discord.com/api/v9";
+ m_szUrl = ppro->m_szApiUrl;
m_szUrl += _url;
m_bMainSite = true;
}
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index 96ba582377..f1df2c2a12 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -62,6 +62,9 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) :
m_bSyncDeleteMsgs(this, "DeleteServerMsgs", true),
m_bSyncDeleteUsers(this, "DeleteServerUsers", true)
{
+ // Hidden setting!
+ m_szApiUrl = getMStringA("ApiUrl", "https://discord.com/api/v9");
+
// Services
CreateProtoService(PS_GETAVATARINFO, &CDiscordProto::GetAvatarInfo);
CreateProtoService(PS_GETAVATARCAPS, &CDiscordProto::GetAvatarCaps);
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index fac698111d..8342ba5724 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -372,6 +372,7 @@ class CDiscordProto : public PROTO<CDiscordProto>
// gateway
CMStringA
+ m_szApiUrl, // Discord API url
m_szGateway, // gateway url
m_szGatewaySessionId, // current session id
m_szCookie, // cookie used for all http queries
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp
index 172faebe47..beef589e30 100644
--- a/protocols/Discord/src/server.cpp
+++ b/protocols/Discord/src/server.cpp
@@ -143,9 +143,17 @@ void CDiscordProto::OnReceiveHistory(MHttpResponse *pReply, AsyncHttpRequest *pR
/////////////////////////////////////////////////////////////////////////////////////////
// retrieves user info
-void CDiscordProto::RetrieveMyInfo()
+void CDiscordProto::OnReceiveGateway(MHttpResponse *pReply, AsyncHttpRequest *)
{
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/users/@me", &CDiscordProto::OnReceiveMyInfo));
+ JsonReply root(pReply);
+ if (!root) {
+ ShutdownSession();
+ return;
+ }
+
+ auto &data = root.data();
+ m_szGateway = data["url"].as_mstring();
+ ForkThread(&CDiscordProto::GatewayThread, nullptr);
}
void CDiscordProto::OnReceiveMyInfo(MHttpResponse *pReply, AsyncHttpRequest*)
@@ -178,20 +186,9 @@ void CDiscordProto::OnReceiveMyInfo(MHttpResponse *pReply, AsyncHttpRequest*)
CheckAvatarChange(0, data["avatar"].as_mstring());
}
-/////////////////////////////////////////////////////////////////////////////////////////
-// finds a gateway address
-
-void CDiscordProto::OnReceiveGateway(MHttpResponse *pReply, AsyncHttpRequest*)
+void CDiscordProto::RetrieveMyInfo()
{
- JsonReply root(pReply);
- if (!root) {
- ShutdownSession();
- return;
- }
-
- auto &data = root.data();
- m_szGateway = data["url"].as_mstring();
- ForkThread(&CDiscordProto::GatewayThread, nullptr);
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/users/@me", &CDiscordProto::OnReceiveMyInfo));
}
/////////////////////////////////////////////////////////////////////////////////////////