diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0c708ce18..016a0a968 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -6507,11 +6507,11 @@ internalLinkTypeLanguageSettings = InternalLinkType; //-If the bot can be added to attachment menu, then use getAttachmentMenuBot to receive information about the bot, then if the bot isn't added to side menu, //-show a disclaimer about Mini Apps being a third-party apps, ask the user to accept their Terms of service and confirm adding the bot to side and attachment menu, //-then if the user accepts the terms and confirms adding, use toggleBotIsAddedToAttachmentMenu to add the bot. -//-Then use getMainWebAppUrl with the given URL and open the returned URL as a Web App +//-Then use getMainWebApp with the given start parameter and open the returned URL as a Web App //@bot_username Username of the bot -//@url URL to be passed to getMainWebAppUrl +//@start_parameter Start parameter to be passed to getMainWebApp //@is_compact True, if the Web App must be opened in the compact mode instead of the full-size mode -internalLinkTypeMainWebApp bot_username:string url:string is_compact:Bool = InternalLinkType; +internalLinkTypeMainWebApp bot_username:string start_parameter:string is_compact:Bool = InternalLinkType; //@description The link is a link to a Telegram message or a forum topic. Call getMessageLinkInfo with the given URL to process the link, //-and then open received forum topic or chat and show the message there diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index 5ff84a3e9..32b189e56 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -530,19 +530,16 @@ class LinkManager::InternalLinkLanguageSettings final : public InternalLink { class LinkManager::InternalLinkMainWebApp final : public InternalLink { string bot_username_; - string url_; + string start_parameter_; string mode_; td_api::object_ptr get_internal_link_type_object() const final { - return td_api::make_object(bot_username_, url_, mode_ == "compact"); + return td_api::make_object(bot_username_, start_parameter_, mode_ == "compact"); } public: InternalLinkMainWebApp(string bot_username, string start_parameter, string mode) - : bot_username_(std::move(bot_username)), mode_(std::move(mode)) { - if (!start_parameter.empty()) { - url_ = PSTRING() << "start://" << start_parameter; - } + : bot_username_(std::move(bot_username)), start_parameter_(std::move(start_parameter)), mode_(std::move(mode)) { } }; @@ -2214,15 +2211,11 @@ Result LinkManager::get_internal_link_impl(const td_api::InternalLinkTyp return Status::Error(400, "Invalid bot username specified"); } string start_parameter; - if (!link->url_.empty()) { - if (!begins_with(link->url_, "start://")) { - return Status::Error(400, "Unsupported link URL specified"); - } - auto start_parameter_slice = Slice(link->url_).substr(8); - if (start_parameter_slice.empty() || !is_valid_start_parameter(start_parameter_slice)) { + if (!link->start_parameter_.empty()) { + if (!is_valid_start_parameter(link->start_parameter_)) { return Status::Error(400, "Invalid start parameter specified"); } - start_parameter = PSTRING() << '=' << start_parameter_slice; + start_parameter = PSTRING() << '=' << link->start_parameter_; } string mode = link->is_compact_ ? "&mode=compact" : ""; if (is_internal) { diff --git a/test/link.cpp b/test/link.cpp index 2f35a9702..cddbc046a 100644 --- a/test/link.cpp +++ b/test/link.cpp @@ -273,8 +273,7 @@ static auto language_settings() { } static auto main_web_app(const td::string &bot_username, const td::string &start_parameter, bool is_compact) { - return td::td_api::make_object( - bot_username, start_parameter.empty() ? td::string() : "start://" + start_parameter, is_compact); + return td::td_api::make_object(bot_username, start_parameter, is_compact); } static auto message(const td::string &url) {