diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 12e7f3616..4bf757553 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -235,7 +235,7 @@ void activateBotCommand( if (const auto bot = msg->getMessageBot()) { bot->session().attachWebView().requestSimple( bot, - button->data); + { .text = button->text, .url = button->data }); } } break; } diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 8cb99738e..a3a860f00 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -168,7 +168,8 @@ void AttachWebView::resolveUsername( if (error.code() == 400) { Ui::ShowMultilineToast({ .text = { - tr::lng_username_not_found(tr::now, lt_user, username) } + tr::lng_username_not_found(tr::now, lt_user, username), + }, }); } }).send(); @@ -176,25 +177,21 @@ void AttachWebView::resolveUsername( void AttachWebView::requestSimple( not_null bot, - const QByteArray &url) { - if (_peer != bot || _bot != bot) { - return; - } + const WebViewButton &button) { cancel(); - _bot = bot; _peer = bot; using Flag = MTPmessages_RequestSimpleWebView::Flag; _requestId = _session->api().request(MTPmessages_RequestSimpleWebView( - MTP_flags(0), + MTP_flags(Flag::f_theme_params), bot->inputUser, - MTP_bytes(url), - MTPDataJSON() + MTP_bytes(button.url), + MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams())) )).done([=](const MTPSimpleWebViewResult &result) { _requestId = 0; result.match([&](const MTPDsimpleWebViewResultUrl &data) { const auto queryId = uint64(); - show(queryId, qs(data.vurl())); + show(queryId, qs(data.vurl()), button.text); }); }).fail([=](const MTP::Error &error) { _requestId = 0; @@ -212,7 +209,7 @@ void AttachWebView::show( cancel(); }); const auto sendData = crl::guard(this, [=](QByteArray data) { - if (_peer != _bot || !queryId) { + if (_peer != _bot) { cancel(); return; } diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h index 5bca12d4b..148ea6de3 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h @@ -32,14 +32,15 @@ public: struct WebViewButton { QString text; QByteArray url; - bool simple = false; }; void request(not_null peer, const QString &botUsername); void request( not_null peer, not_null bot, const WebViewButton &button = WebViewButton()); - void requestSimple(not_null bot, const QByteArray &url); + void requestSimple( + not_null bot, + const WebViewButton &button); private: void cancel();