From 9bd79fa9cbff4a517d171c58e8c2ad2d4fa7a02c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 11 Apr 2025 16:47:40 +0300 Subject: Discord: popup added if captcha is required to join the Guild --- protocols/Discord/src/menus.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'protocols/Discord/src/menus.cpp') 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; -- cgit v1.2.3