summaryrefslogtreecommitdiff
path: root/protocols/Discord/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-04-11 16:47:40 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-04-11 16:47:40 +0300
commit9bd79fa9cbff4a517d171c58e8c2ad2d4fa7a02c (patch)
tree1f329f5ff01205934c518f94051a371995821cc4 /protocols/Discord/src
parenta375401a03eac7e1e8d8a76f8074c2de81797019 (diff)
Discord: popup added if captcha is required to join the Guild
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r--protocols/Discord/src/menus.cpp16
-rw-r--r--protocols/Discord/src/proto.h1
2 files changed, 16 insertions, 1 deletions
diff --git a/protocols/Discord/src/menus.cpp b/protocols/Discord/src/menus.cpp
index 0feafe3e3a..4f94d66312 100644
--- a/protocols/Discord/src/menus.cpp
+++ b/protocols/Discord/src/menus.cpp
@@ -53,12 +53,26 @@ INT_PTR CDiscordProto::OnMenuDatabaseHistory(WPARAM hContact, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
+void CDiscordProto::OnReceiveJoin(MHttpResponse *pResponse, AsyncHttpRequest *)
+{
+ if (pResponse->resultCode == 400) {
+ auto reply = JSONNode::parse(pResponse->body);
+ if (reply && reply["captcha_key"]) {
+ POPUPDATAW popup;
+ popup.lchIcon = IcoLib_GetIconByHandle(Skin_GetIconHandle(SKINICON_ERROR), true);
+ wcscpy_s(popup.lpwzContactName, m_tszUserName);
+ mir_snwprintf(popup.lpwzText, TranslateT("You need to enter a captcha to join this server. Open this link in a browser."));
+ PUAddPopupW(&popup);
+ }
+ }
+}
+
INT_PTR CDiscordProto::OnMenuJoinGuild(WPARAM, LPARAM)
{
ENTER_STRING es = { m_szModuleName, "guild_name", TranslateT("Enter invitation code you received"), nullptr, ESF_COMBO, 5 };
if (EnterString(&es)) {
CMStringA szUrl(FORMAT, "/invites/%S", es.ptszResult);
- Push(new AsyncHttpRequest(this, REQUEST_POST, szUrl, nullptr));
+ Push(new AsyncHttpRequest(this, REQUEST_POST, szUrl, &CDiscordProto::OnReceiveJoin));
mir_free(es.ptszResult);
}
return 0;
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index d0b7b24117..28f2bda045 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -615,6 +615,7 @@ public:
void OnReceiveCreateChannel(MHttpResponse*, AsyncHttpRequest*);
void OnReceiveFile(MHttpResponse*, AsyncHttpRequest*);
void OnReceiveGateway(MHttpResponse*, AsyncHttpRequest*);
+ void OnReceiveJoin(MHttpResponse*, AsyncHttpRequest*);
void OnReceiveLogout(MHttpResponse*, AsyncHttpRequest*);
void OnReceiveMarkRead(MHttpResponse*, AsyncHttpRequest *);
void OnReceiveMessageAck(MHttpResponse*, AsyncHttpRequest*);