Rename web view to web app.

This commit is contained in:
levlam 2022-03-31 16:42:59 +03:00
parent 68db9a03cc
commit e54fac174a
10 changed files with 70 additions and 70 deletions

View File

@ -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<PassportElementType> = 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<InputInlineQueryResult> 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

View File

@ -29,12 +29,12 @@
namespace td {
class RequestWebViewQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::webViewInfo>> promise_;
Promise<td_api::object_ptr<td_api::webAppInfo>> promise_;
DialogId dialog_id_;
bool from_attach_menu_ = false;
public:
explicit RequestWebViewQuery(Promise<td_api::object_ptr<td_api::webViewInfo>> &&promise)
explicit RequestWebViewQuery(Promise<td_api::object_ptr<td_api::webAppInfo>> &&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<td_api::webViewInfo>(ptr->query_id_, ptr->url_));
promise_.set_value(td_api::make_object<td_api::webAppInfo>(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<td_api::themeParameters> &&theme,
Promise<td_api::object_ptr<td_api::webViewInfo>> &&promise) {
Promise<td_api::object_ptr<td_api::webAppInfo>> &&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));

View File

@ -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<td_api::themeParameters> &&theme,
Promise<td_api::object_ptr<td_api::webViewInfo>> &&promise);
Promise<td_api::object_ptr<td_api::webAppInfo>> &&promise);
void reload_attach_menu_bots(Promise<Unit> &&promise);

View File

@ -231,10 +231,10 @@ class SendWebViewDataQuery final : public Td::ResultHandler {
};
class SendWebViewResultMessageQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::sentWebViewMessage>> promise_;
Promise<td_api::object_ptr<td_api::sentWebAppMessage>> promise_;
public:
explicit SendWebViewResultMessageQuery(Promise<td_api::object_ptr<td_api::sentWebViewMessage>> &&promise)
explicit SendWebViewResultMessageQuery(Promise<td_api::object_ptr<td_api::sentWebAppMessage>> &&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<td_api::sentWebViewMessage>(
promise_.set_value(td_api::make_object<td_api::sentWebAppMessage>(
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<td_api::InputInlineQueryResult> &&input_result,
Promise<td_api::object_ptr<td_api::sentWebViewMessage>> &&promise) const {
Promise<td_api::object_ptr<td_api::sentWebAppMessage>> &&promise) const {
CHECK(td_->auth_manager_->is_bot());
TRY_RESULT_PROMISE(promise, result, get_input_bot_inline_result(std::move(input_result), nullptr, nullptr));

View File

@ -52,7 +52,7 @@ class InlineQueriesManager final : public Actor {
void answer_web_view_query(const string &web_view_query_id,
td_api::object_ptr<td_api::InputInlineQueryResult> &&input_result,
Promise<td_api::object_ptr<td_api::sentWebViewMessage>> &&promise) const;
Promise<td_api::object_ptr<td_api::sentWebAppMessage>> &&promise) const;
uint64 send_inline_query(UserId bot_user_id, DialogId dialog_id, Location user_location, const string &query,
const string &offset, Promise<Unit> &&promise);

View File

@ -5130,11 +5130,11 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
}
case MessageContentType::WebViewDataSent: {
const auto *m = static_cast<const MessageWebViewDataSent *>(content);
return make_tl_object<td_api::messageWebViewDataSent>(m->button_text);
return make_tl_object<td_api::messageWebAppDataSent>(m->button_text);
}
case MessageContentType::WebViewDataReceived: {
const auto *m = static_cast<const MessageWebViewDataReceived *>(content);
return make_tl_object<td_api::messageWebViewDataReceived>(m->button_text, m->data);
return make_tl_object<td_api::messageWebAppDataReceived>(m->button_text, m->data);
}
default:
UNREACHABLE();

View File

@ -440,19 +440,19 @@ static Result<KeyboardButton> get_keyboard_button(tl_object_ptr<td_api::keyboard
}
break;
}
case td_api::keyboardButtonTypeWebView::ID: {
case td_api::keyboardButtonTypeWebApp::ID: {
if (!request_buttons_allowed) {
return Status::Error(400, "Web view can be used in private chats only");
}
auto button_type = move_tl_object_as<td_api::keyboardButtonTypeWebView>(button->type_);
auto button_type = move_tl_object_as<td_api::keyboardButtonTypeWebApp>(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<InlineKeyboardButton> get_inline_keyboard_button(tl_object_ptr<td_
}
break;
}
case td_api::inlineKeyboardButtonTypeWebView::ID: {
auto button_type = move_tl_object_as<td_api::inlineKeyboardButtonTypeWebView>(button->type_);
case td_api::inlineKeyboardButtonTypeWebApp::ID: {
auto button_type = move_tl_object_as<td_api::inlineKeyboardButtonTypeWebApp>(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<td_api::keyboardButton> get_keyboard_button_object(const Ke
type = make_tl_object<td_api::keyboardButtonTypeRequestPoll>(true, false);
break;
case KeyboardButton::Type::WebView:
type = make_tl_object<td_api::keyboardButtonTypeWebView>(keyboard_button.url);
type = make_tl_object<td_api::keyboardButtonTypeWebApp>(keyboard_button.url);
break;
default:
UNREACHABLE();
@ -902,7 +902,7 @@ static tl_object_ptr<td_api::inlineKeyboardButton> get_inline_keyboard_button_ob
"get_inline_keyboard_button_object"));
break;
case InlineKeyboardButton::Type::WebView:
type = make_tl_object<td_api::inlineKeyboardButtonTypeWebView>(keyboard_button.data);
type = make_tl_object<td_api::inlineKeyboardButtonTypeWebApp>(keyboard_button.data);
break;
default:
UNREACHABLE();

View File

@ -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));
}

View File

@ -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);

View File

@ -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<td_api::toggleBotIsAddedToAttachMenu>(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<td_api::getWebViewUrl>(user_id, url, get_theme_parameters()));
} else if (op == "swvd") {
send_request(td_api::make_object<td_api::getWebAppUrl>(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<td_api::sendWebViewData>(user_id, button_text, data));
} else if (op == "owv") {
send_request(td_api::make_object<td_api::sendWebAppData>(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<td_api::openWebView>(chat_id, bot_user_id, url, from_bot_menu,
get_theme_parameters(), reply_to_message_id));
send_request(td_api::make_object<td_api::openWebApp>(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;