From e54fac174a8871c4ba75507881a4689163eaf668 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 31 Mar 2022 16:42:59 +0300 Subject: [PATCH] Rename web view to web app. --- td/generate/scheme/td_api.tl | 60 ++++++++++++++-------------- td/telegram/AttachMenuManager.cpp | 8 ++-- td/telegram/AttachMenuManager.h | 2 +- td/telegram/InlineQueriesManager.cpp | 8 ++-- td/telegram/InlineQueriesManager.h | 2 +- td/telegram/MessageContent.cpp | 4 +- td/telegram/ReplyMarkup.cpp | 22 +++++----- td/telegram/Td.cpp | 12 +++--- td/telegram/Td.h | 8 ++-- td/telegram/cli.cpp | 14 +++---- 10 files changed, 70 insertions(+), 70 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index fcb29b9ea..738b8d72c 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1125,8 +1125,8 @@ keyboardButtonTypeRequestLocation = KeyboardButtonType; //@description A button that allows the user to create and send a poll when pressed; available only in private chats @force_regular If true, only regular polls must be allowed to create @force_quiz If true, only polls in quiz mode must be allowed to create keyboardButtonTypeRequestPoll force_regular:Bool force_quiz:Bool = KeyboardButtonType; -//@description A button that opens a specified URL in web view by calling getWebViewUrl @url An HTTP URL to pass to getWebViewUrl -keyboardButtonTypeWebView url:string = KeyboardButtonType; +//@description A button that opens a web app by calling getWebAppUrl @url An HTTP URL to pass to getWebAppUrl +keyboardButtonTypeWebApp url:string = KeyboardButtonType; //@description Represents a single button in a bot keyboard @text Text of the button @type Type of the button @@ -1141,8 +1141,8 @@ inlineKeyboardButtonTypeUrl url:string = InlineKeyboardButtonType; //@description A button that opens a specified URL and automatically authorize the current user by calling getLoginUrlInfo @url An HTTP URL to pass to getLoginUrlInfo @id Unique button identifier @forward_text If non-empty, new text of the button in forwarded messages inlineKeyboardButtonTypeLoginUrl url:string id:int53 forward_text:string = InlineKeyboardButtonType; -//@description A button that opens a specified URL in web view by calling openWebView @url An HTTP URL to pass to openWebView -inlineKeyboardButtonTypeWebView url:string = InlineKeyboardButtonType; +//@description A button that opens a web app by calling openWebApp @url An HTTP URL to pass to openWebApp +inlineKeyboardButtonTypeWebApp url:string = InlineKeyboardButtonType; //@description A button that sends a callback query to a bot @data Data to be sent to the bot via a callback query inlineKeyboardButtonTypeCallback data:bytes = InlineKeyboardButtonType; @@ -1201,8 +1201,8 @@ loginUrlInfoOpen url:string skip_confirm:Bool = LoginUrlInfo; loginUrlInfoRequestConfirmation url:string domain:string bot_user_id:int53 request_write_access:Bool = LoginUrlInfo; -//@description Contains information about URL to be opened in web view @query_id Unique identifier for the web view opening query @url The URL to open in web view -webViewInfo query_id:int64 url:string = WebViewInfo; +//@description Contains information about a web app @launch_id Unique identifier for the web app launch @url A web app URL to open in a web view +webAppInfo launch_id:int64 url:string = WebAppInfo; //@description Contains information about a message thread @@ -1945,11 +1945,11 @@ messageContactRegistered = MessageContent; //@description The current user has connected a website by logging in using Telegram Login Widget on it @domain_name Domain name of the connected website messageWebsiteConnected domain_name:string = MessageContent; -//@description Data from web view has been sent to a bot @button_text Text of the keyboardButtonTypeWebView button, which opened the web view -messageWebViewDataSent button_text:string = MessageContent; +//@description Data from a web app has been sent to a bot @button_text Text of the keyboardButtonTypeWebApp button, which opened the web app +messageWebAppDataSent button_text:string = MessageContent; -//@description Data from web view has been received; for bots only @button_text Text of the keyboardButtonTypeWebView button, which opened the web view @data Received data -messageWebViewDataReceived button_text:string data:string = MessageContent; +//@description Data from a web app has been received; for bots only @button_text Text of the keyboardButtonTypeWebApp button, which opened the web app @data Received data +messageWebAppDataReceived button_text:string data:string = MessageContent; //@description Telegram Passport data has been sent to a bot @types List of Telegram Passport element types sent messagePassportDataSent types:vector = MessageContent; @@ -2528,8 +2528,8 @@ attachMenuBotColor light_color:int32 dark_color:int32 = AttachMenuBotColor; //@icon_color Color to highlight selected icon of the bot if appropriate; may be null attachMenuBot bot_user_id:int53 name:string name_color:attachMenuBotColor default_icon:file ios_static_icon:file ios_animated_icon:file android_icon:file macos_icon:file icon_color:attachMenuBotColor = AttachMenuBot; -//@description Information about the message sent by answerWebViewQuery @inline_message_id Identifier of the sent inline message, if known -sentWebViewMessage inline_message_id:string = SentWebViewMessage; +//@description Information about the message sent by answerWebAppQuery @inline_message_id Identifier of the sent inline message, if known +sentWebAppMessage inline_message_id:string = SentWebAppMessage; //@description Contains an HTTP URL @url The URL @@ -4859,29 +4859,29 @@ getInlineQueryResults bot_user_id:int53 chat_id:int53 user_location:location que answerInlineQuery inline_query_id:int64 is_personal:Bool results:vector cache_time:int32 next_offset:string switch_pm_text:string switch_pm_parameter:string = Ok; -//@description Returns an HTTPS URL to open in a web view when keyboardButtonTypeWebView button is pressed +//@description Returns an HTTPS URL of a web app to open after keyboardButtonTypeWebApp button is pressed //@bot_user_id Identifier of the target bot -//@url The URL from the keyboardButtonTypeWebView button -//@theme Preferred web view theme; pass null to use the default theme -getWebViewUrl bot_user_id:int53 url:string theme:themeParameters = HttpUrl; +//@url The URL from the keyboardButtonTypeWebApp button +//@theme Preferred web app theme; pass null to use the default theme +getWebAppUrl bot_user_id:int53 url:string theme:themeParameters = HttpUrl; -//@description Sends data received from keyboardButtonTypeWebView web view to a bot -//@bot_user_id Identifier of the target bot @button_text Text of the keyboardButtonTypeWebView button, which opened the web view @data Received data -sendWebViewData bot_user_id:int53 button_text:string data:string = Ok; +//@description Sends data received from a keyboardButtonTypeWebApp web app to a bot +//@bot_user_id Identifier of the target bot @button_text Text of the keyboardButtonTypeWebApp button, which opened the web app @data Received data +sendWebAppData bot_user_id:int53 button_text:string data:string = Ok; -//@description Informs TDLib that a web view is being opened from attach menu, bot menu, internalLinkTypeAttachMenuBot links, or an inlineKeyboardButtonTypeWebView button -//@chat_id Identifier of the chat in which web view is opened. Web view can be opened only in private chats for now -//@bot_user_id Identifier of the target bot, providing web view -//@url The URL from the inlineKeyboardButtonTypeWebView button or the internalLinkTypeAttachMenuBot link, or an empty string otherwise -//@from_bot_menu Pass true if the web view is opened from bot menu -//@theme Preferred web view theme; pass null to use the default theme -//@reply_to_message_id Identifier of the message to reply to by web view-generated message or 0 -openWebView chat_id:int53 bot_user_id:int53 url:string from_bot_menu:Bool theme:themeParameters reply_to_message_id:int53 = WebViewInfo; +//@description Informs TDLib that a web app is being opened from attach menu, bot menu, internalLinkTypeAttachMenuBot links, or an inlineKeyboardButtonTypeWebApp button +//@chat_id Identifier of the chat in which the web app is opened. Web apps can be opened only in private chats for now +//@bot_user_id Identifier of the bot, providing the web app +//@url The URL from the inlineKeyboardButtonTypeWebApp button or the internalLinkTypeAttachMenuBot link, or an empty string otherwise +//@from_bot_menu Pass true if the web app is opened from bot menu +//@theme Preferred web app theme; pass null to use the default theme +//@reply_to_message_id Identifier of the replied message for the message sent by the web app or 0 +openWebApp chat_id:int53 bot_user_id:int53 url:string from_bot_menu:Bool theme:themeParameters reply_to_message_id:int53 = WebAppInfo; -//@description Sets the result of interaction with web view and sends corresponding message on behalf of the user to the chat from which the query originated; for bots only -//@web_view_query_id Identifier of the web view query +//@description Sets the result of interaction with a web app and sends corresponding message on behalf of the user to the chat from which the query originated; for bots only +//@web_app_query_id Identifier of the web app query //@result The result of the query -answerWebViewQuery web_view_query_id:string result:InputInlineQueryResult = SentWebViewMessage; +answerWebAppQuery web_app_query_id:string result:InputInlineQueryResult = SentWebAppMessage; //@description Sends a callback query to a bot and returns an answer. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires @chat_id Identifier of the chat with the message @message_id Identifier of the message from which the query originated @payload Query payload diff --git a/td/telegram/AttachMenuManager.cpp b/td/telegram/AttachMenuManager.cpp index bfd80f072..9a70f2fb0 100644 --- a/td/telegram/AttachMenuManager.cpp +++ b/td/telegram/AttachMenuManager.cpp @@ -29,12 +29,12 @@ namespace td { class RequestWebViewQuery final : public Td::ResultHandler { - Promise> promise_; + Promise> promise_; DialogId dialog_id_; bool from_attach_menu_ = false; public: - explicit RequestWebViewQuery(Promise> &&promise) + explicit RequestWebViewQuery(Promise> &&promise) : promise_(std::move(promise)) { } @@ -89,7 +89,7 @@ class RequestWebViewQuery final : public Td::ResultHandler { } auto ptr = result_ptr.move_as_ok(); - promise_.set_value(td_api::make_object(ptr->query_id_, ptr->url_)); + promise_.set_value(td_api::make_object(ptr->query_id_, ptr->url_)); } void on_error(Status status) final { @@ -395,7 +395,7 @@ bool AttachMenuManager::is_active() const { void AttachMenuManager::request_web_view(DialogId dialog_id, UserId bot_user_id, MessageId reply_to_message_id, string &&url, bool from_bot_menu, td_api::object_ptr &&theme, - Promise> &&promise) { + Promise> &&promise) { TRY_STATUS_PROMISE(promise, td_->contacts_manager_->get_bot_data(bot_user_id)); TRY_RESULT_PROMISE(promise, input_user, td_->contacts_manager_->get_input_user(bot_user_id)); diff --git a/td/telegram/AttachMenuManager.h b/td/telegram/AttachMenuManager.h index aae8d7e5b..015258b82 100644 --- a/td/telegram/AttachMenuManager.h +++ b/td/telegram/AttachMenuManager.h @@ -31,7 +31,7 @@ class AttachMenuManager final : public Actor { void request_web_view(DialogId dialog_id, UserId bot_user_id, MessageId reply_to_message_id, string &&url, bool from_bot_menu, td_api::object_ptr &&theme, - Promise> &&promise); + Promise> &&promise); void reload_attach_menu_bots(Promise &&promise); diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index 5ce49d65a..8ea9b3f1b 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -231,10 +231,10 @@ class SendWebViewDataQuery final : public Td::ResultHandler { }; class SendWebViewResultMessageQuery final : public Td::ResultHandler { - Promise> promise_; + Promise> promise_; public: - explicit SendWebViewResultMessageQuery(Promise> &&promise) + explicit SendWebViewResultMessageQuery(Promise> &&promise) : promise_(std::move(promise)) { } @@ -251,7 +251,7 @@ class SendWebViewResultMessageQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SendWebViewResultMessageQuery: " << to_string(ptr); - promise_.set_value(td_api::make_object( + promise_.set_value(td_api::make_object( InlineQueriesManager::get_inline_message_id(std::move(ptr->msg_id_)))); } @@ -521,7 +521,7 @@ void InlineQueriesManager::send_web_view_data(UserId bot_user_id, string &&butto void InlineQueriesManager::answer_web_view_query( const string &web_view_query_id, td_api::object_ptr &&input_result, - Promise> &&promise) const { + Promise> &&promise) const { CHECK(td_->auth_manager_->is_bot()); TRY_RESULT_PROMISE(promise, result, get_input_bot_inline_result(std::move(input_result), nullptr, nullptr)); diff --git a/td/telegram/InlineQueriesManager.h b/td/telegram/InlineQueriesManager.h index aec40304c..8c3effa6d 100644 --- a/td/telegram/InlineQueriesManager.h +++ b/td/telegram/InlineQueriesManager.h @@ -52,7 +52,7 @@ class InlineQueriesManager final : public Actor { void answer_web_view_query(const string &web_view_query_id, td_api::object_ptr &&input_result, - Promise> &&promise) const; + Promise> &&promise) const; uint64 send_inline_query(UserId bot_user_id, DialogId dialog_id, Location user_location, const string &query, const string &offset, Promise &&promise); diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 1c3aa5518..7d3714fa0 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -5130,11 +5130,11 @@ tl_object_ptr get_message_content_object(const MessageCo } case MessageContentType::WebViewDataSent: { const auto *m = static_cast(content); - return make_tl_object(m->button_text); + return make_tl_object(m->button_text); } case MessageContentType::WebViewDataReceived: { const auto *m = static_cast(content); - return make_tl_object(m->button_text, m->data); + return make_tl_object(m->button_text, m->data); } default: UNREACHABLE(); diff --git a/td/telegram/ReplyMarkup.cpp b/td/telegram/ReplyMarkup.cpp index 9640b6f6d..5785d97b4 100644 --- a/td/telegram/ReplyMarkup.cpp +++ b/td/telegram/ReplyMarkup.cpp @@ -440,19 +440,19 @@ static Result get_keyboard_button(tl_object_ptr(button->type_); + auto button_type = move_tl_object_as(button->type_); auto user_id = LinkManager::get_link_user_id(button_type->url_); if (user_id.is_valid()) { - return Status::Error(400, "Link to a user can't be used in web view URL buttons"); + return Status::Error(400, "Link to a user can't be used in web app URL buttons"); } auto r_url = LinkManager::check_link(button_type->url_, true, true); if (r_url.is_error()) { - return Status::Error(400, "Inline keyboard button web view URL is invalid"); + return Status::Error(400, "Inline keyboard button web app URL is invalid"); } current_button.type = KeyboardButton::Type::WebView; current_button.url = std::move(button_type->url_); @@ -566,20 +566,20 @@ static Result get_inline_keyboard_button(tl_object_ptr(button->type_); + case td_api::inlineKeyboardButtonTypeWebApp::ID: { + auto button_type = move_tl_object_as(button->type_); auto user_id = LinkManager::get_link_user_id(button_type->url_); if (user_id.is_valid()) { - return Status::Error(400, "Link to a user can't be used in web view URL buttons"); + return Status::Error(400, "Link to a user can't be used in web app URL buttons"); } auto r_url = LinkManager::check_link(button_type->url_, true, true); if (r_url.is_error()) { - return Status::Error(400, "Inline keyboard button web view URL is invalid"); + return Status::Error(400, "Inline keyboard button web app URL is invalid"); } current_button.type = InlineKeyboardButton::Type::WebView; current_button.data = r_url.move_as_ok(); if (!clean_input_string(current_button.data)) { - return Status::Error(400, "Inline keyboard button web view URL must be encoded in UTF-8"); + return Status::Error(400, "Inline keyboard button web app URL must be encoded in UTF-8"); } break; } @@ -858,7 +858,7 @@ static tl_object_ptr get_keyboard_button_object(const Ke type = make_tl_object(true, false); break; case KeyboardButton::Type::WebView: - type = make_tl_object(keyboard_button.url); + type = make_tl_object(keyboard_button.url); break; default: UNREACHABLE(); @@ -902,7 +902,7 @@ static tl_object_ptr get_inline_keyboard_button_ob "get_inline_keyboard_button_object")); break; case InlineKeyboardButton::Type::WebView: - type = make_tl_object(keyboard_button.data); + type = make_tl_object(keyboard_button.data); break; default: UNREACHABLE(); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index f20a59893..fc705f9ed 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7336,7 +7336,7 @@ void Td::on_request(uint64 id, td_api::answerInlineQuery &request) { request.next_offset_, request.switch_pm_text_, request.switch_pm_parameter_, std::move(promise)); } -void Td::on_request(uint64 id, td_api::getWebViewUrl &request) { +void Td::on_request(uint64 id, td_api::getWebAppUrl &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.url_); CREATE_REQUEST_PROMISE(); @@ -7351,7 +7351,7 @@ void Td::on_request(uint64 id, td_api::getWebViewUrl &request) { std::move(request.theme_), std::move(query_promise)); } -void Td::on_request(uint64 id, td_api::sendWebViewData &request) { +void Td::on_request(uint64 id, td_api::sendWebAppData &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.button_text_); CLEAN_INPUT_STRING(request.data_); @@ -7360,7 +7360,7 @@ void Td::on_request(uint64 id, td_api::sendWebViewData &request) { std::move(request.data_), std::move(promise)); } -void Td::on_request(uint64 id, td_api::openWebView &request) { +void Td::on_request(uint64 id, td_api::openWebApp &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.url_); CREATE_REQUEST_PROMISE(); @@ -7369,11 +7369,11 @@ void Td::on_request(uint64 id, td_api::openWebView &request) { request.from_bot_menu_, std::move(request.theme_), std::move(promise)); } -void Td::on_request(uint64 id, td_api::answerWebViewQuery &request) { +void Td::on_request(uint64 id, td_api::answerWebAppQuery &request) { CHECK_IS_BOT(); - CLEAN_INPUT_STRING(request.web_view_query_id_); + CLEAN_INPUT_STRING(request.web_app_query_id_); CREATE_REQUEST_PROMISE(); - inline_queries_manager_->answer_web_view_query(request.web_view_query_id_, std::move(request.result_), + inline_queries_manager_->answer_web_view_query(request.web_app_query_id_, std::move(request.result_), std::move(promise)); } diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 96d94d77f..43440b56a 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1155,13 +1155,13 @@ class Td final : public Actor { void on_request(uint64 id, td_api::answerInlineQuery &request); - void on_request(uint64 id, td_api::getWebViewUrl &request); + void on_request(uint64 id, td_api::getWebAppUrl &request); - void on_request(uint64 id, td_api::sendWebViewData &request); + void on_request(uint64 id, td_api::sendWebAppData &request); - void on_request(uint64 id, td_api::openWebView &request); + void on_request(uint64 id, td_api::openWebApp &request); - void on_request(uint64 id, td_api::answerWebViewQuery &request); + void on_request(uint64 id, td_api::answerWebAppQuery &request); void on_request(uint64 id, td_api::getCallbackQueryAnswer &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 3891fe8e9..6847f01f0 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3428,26 +3428,26 @@ class CliClient final : public Actor { bool is_added; get_args(args, user_id, is_added); send_request(td_api::make_object(user_id, is_added)); - } else if (op == "gwvu") { + } else if (op == "gwau") { UserId user_id; string url; get_args(args, user_id, url); - send_request(td_api::make_object(user_id, url, get_theme_parameters())); - } else if (op == "swvd") { + send_request(td_api::make_object(user_id, url, get_theme_parameters())); + } else if (op == "swad") { UserId user_id; string button_text; string data; get_args(args, user_id, button_text, data); - send_request(td_api::make_object(user_id, button_text, data)); - } else if (op == "owv") { + send_request(td_api::make_object(user_id, button_text, data)); + } else if (op == "owa") { ChatId chat_id; UserId bot_user_id; string url; bool from_bot_menu; MessageId reply_to_message_id; get_args(args, chat_id, bot_user_id, url, from_bot_menu, reply_to_message_id); - send_request(td_api::make_object(chat_id, bot_user_id, url, from_bot_menu, - get_theme_parameters(), reply_to_message_id)); + send_request(td_api::make_object(chat_id, bot_user_id, url, from_bot_menu, + get_theme_parameters(), reply_to_message_id)); } else if (op == "sca") { ChatId chat_id; string message_thread_id;