diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 568358cb6..6d84b4a5a 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -9776,11 +9776,14 @@ getBusinessChatLinks = BusinessChatLinks; //@link_info Description of the link to create createBusinessChatLink link_info:inputBusinessChatLink = BusinessChatLink; -//@description Edits existing business chat link for the current account. Requires Telegram Business subscription. Returns the edited link +//@description Edits a business chat link of the current account. Requires Telegram Business subscription. Returns the edited link //@link The link to edit //@link_info New description of the link editBusinessChatLink link:string link_info:inputBusinessChatLink = BusinessChatLink; +//@description Deletes a business chat link of the current account @link The link to delete +deleteBusinessChatLink link:string = Ok; + //@description Returns an HTTPS link, which can be used to get information about the current user getUserLink = UserLink; diff --git a/td/telegram/BusinessManager.cpp b/td/telegram/BusinessManager.cpp index 1657e8b41..b1379201d 100644 --- a/td/telegram/BusinessManager.cpp +++ b/td/telegram/BusinessManager.cpp @@ -280,6 +280,31 @@ class EditBusinessChatLinkQuery final : public Td::ResultHandler { } }; +class DeleteBusinessChatLinkQuery final : public Td::ResultHandler { + Promise promise_; + + public: + explicit DeleteBusinessChatLinkQuery(Promise &&promise) : promise_(std::move(promise)) { + } + + void send(const string &link) { + send_query(G()->net_query_creator().create(telegram_api::account_deleteBusinessChatLink(link), {{"me"}})); + } + + void on_result(BufferSlice packet) final { + auto result_ptr = fetch_result(packet); + if (result_ptr.is_error()) { + return on_error(result_ptr.move_as_error()); + } + + promise_.set_value(Unit()); + } + + void on_error(Status status) final { + promise_.set_error(std::move(status)); + } +}; + class UpdateBusinessLocationQuery final : public Td::ResultHandler { Promise promise_; DialogLocation location_; @@ -523,6 +548,10 @@ void BusinessManager::edit_business_chat_link(const string &link, ->send(link, InputBusinessChatLink(td_, std::move(link_info))); } +void BusinessManager::delete_business_chat_link(const string &link, Promise &&promise) { + td_->create_handler(std::move(promise))->send(link); +} + void BusinessManager::set_business_location(DialogLocation &&location, Promise &&promise) { td_->create_handler(std::move(promise))->send(std::move(location)); } diff --git a/td/telegram/BusinessManager.h b/td/telegram/BusinessManager.h index 2d2c6ae61..ec0299c43 100644 --- a/td/telegram/BusinessManager.h +++ b/td/telegram/BusinessManager.h @@ -46,6 +46,8 @@ class BusinessManager final : public Actor { void edit_business_chat_link(const string &link, td_api::object_ptr &&link_info, Promise> &&promise); + void delete_business_chat_link(const string &link, Promise &&promise); + void set_business_location(DialogLocation &&location, Promise &&promise); void set_business_work_hours(BusinessWorkHours &&work_hours, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 1d98a6875..0db36ed9a 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -8004,6 +8004,13 @@ void Td::on_request(uint64 id, td_api::editBusinessChatLink &request) { business_manager_->edit_business_chat_link(request.link_, std::move(request.link_info_), std::move(promise)); } +void Td::on_request(uint64 id, td_api::deleteBusinessChatLink &request) { + CHECK_IS_USER(); + CLEAN_INPUT_STRING(request.link_); + CREATE_OK_REQUEST_PROMISE(); + business_manager_->delete_business_chat_link(request.link_, std::move(promise)); +} + void Td::on_request(uint64 id, td_api::setSupergroupUsername &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.username_); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 0d29059e2..add345173 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1449,6 +1449,8 @@ class Td final : public Actor { void on_request(uint64 id, td_api::editBusinessChatLink &request); + void on_request(uint64 id, td_api::deleteBusinessChatLink &request); + void on_request(uint64 id, td_api::setSupergroupUsername &request); void on_request(uint64 id, td_api::toggleSupergroupUsernameIsActive &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index c2cf9bd06..18dc0e054 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -6184,6 +6184,8 @@ class CliClient final : public Actor { get_args(args, link, text, title); send_request(td_api::make_object( link, td_api::make_object(as_formatted_text(text), title))); + } else if (op == "dbcl") { + send_request(td_api::make_object(args)); } else if (op == "gbc") { send_request(td_api::make_object(args.empty() ? business_connection_id_ : args)); } else if (op == "sco") {