diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index adcf284be..280457cdc 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -9477,6 +9477,9 @@ setBusinessGreetingMessageSettings greeting_message_settings:businessGreetingMes //@description Changes the business away message settings of the current user. Requires Telegram Business subscription @away_message_settings The new settings for the away message of the business; pass null to disable the away message setBusinessAwayMessageSettings away_message_settings:businessAwayMessageSettings = Ok; +//@description Changes the business intro of the current user. Requires Telegram Business subscription @intro The new intro of the business; pass null to remove the intro +setBusinessIntro intro:inputBusinessIntro = Ok; + //@description Changes the phone number of the user and sends an authentication code to the user's new phone number; for official Android and iOS applications only. On success, returns information about the sent code //@phone_number The new phone number of the user in international format //@settings Settings for the authentication of the user's phone number; pass null to use default settings diff --git a/td/telegram/BusinessIntro.cpp b/td/telegram/BusinessIntro.cpp index e94d6347d..f2058a40a 100644 --- a/td/telegram/BusinessIntro.cpp +++ b/td/telegram/BusinessIntro.cpp @@ -7,6 +7,7 @@ #include "td/telegram/BusinessIntro.h" #include "td/telegram/files/FileManager.h" +#include "td/telegram/misc.h" #include "td/telegram/StickersManager.h" #include "td/telegram/Td.h" @@ -16,6 +17,12 @@ BusinessIntro::BusinessIntro(Td *td, telegram_api::object_ptrtitle_)) { + intro->title_.clear(); + } + if (!clean_input_string(intro->description_)) { + intro->description_.clear(); + } title_ = std::move(intro->title_); description_ = std::move(intro->description_); sticker_file_id_ = diff --git a/td/telegram/BusinessManager.cpp b/td/telegram/BusinessManager.cpp index 0008eecad..1c69c732e 100644 --- a/td/telegram/BusinessManager.cpp +++ b/td/telegram/BusinessManager.cpp @@ -9,6 +9,7 @@ #include "td/telegram/BusinessAwayMessage.h" #include "td/telegram/BusinessConnectedBot.h" #include "td/telegram/BusinessGreetingMessage.h" +#include "td/telegram/BusinessIntro.h" #include "td/telegram/BusinessRecipients.h" #include "td/telegram/BusinessWorkHours.h" #include "td/telegram/ContactsManager.h" @@ -249,6 +250,41 @@ class UpdateBusinessAwayMessageQuery final : public Td::ResultHandler { } }; +class UpdateBusinessIntroQuery final : public Td::ResultHandler { + Promise promise_; + BusinessIntro intro_; + + public: + explicit UpdateBusinessIntroQuery(Promise &&promise) : promise_(std::move(promise)) { + } + + void send(BusinessIntro &&intro) { + intro_ = std::move(intro); + int32 flags = 0; + if (!intro_.is_empty()) { + flags |= telegram_api::account_updateBusinessIntro::INTRO_MASK; + } + + send_query(G()->net_query_creator().create( + telegram_api::account_updateBusinessIntro(flags, intro_.get_input_business_intro(td_)), {{"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()); + } + + td_->contacts_manager_->on_update_user_intro(td_->contacts_manager_->get_my_id(), std::move(intro_)); + + promise_.set_value(Unit()); + } + + void on_error(Status status) final { + promise_.set_error(std::move(status)); + } +}; + BusinessManager::BusinessManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) { } @@ -292,4 +328,8 @@ void BusinessManager::set_business_away_message(BusinessAwayMessage &&away_messa td_->create_handler(std::move(promise))->send(std::move(away_message)); } +void BusinessManager::set_business_intro(BusinessIntro &&intro, Promise &&promise) { + td_->create_handler(std::move(promise))->send(std::move(intro)); +} + } // namespace td diff --git a/td/telegram/BusinessManager.h b/td/telegram/BusinessManager.h index b47731b75..614e46712 100644 --- a/td/telegram/BusinessManager.h +++ b/td/telegram/BusinessManager.h @@ -18,6 +18,7 @@ namespace td { class BusinessAwayMessage; class BusinessGreetingMessage; +class BusinessIntro; class BusinessWorkHours; class DialogLocation; class Td; @@ -40,6 +41,8 @@ class BusinessManager final : public Actor { void set_business_away_message(BusinessAwayMessage &&away_message, Promise &&promise); + void set_business_intro(BusinessIntro &&intro, Promise &&promise); + private: void tear_down() final; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 611721253..e34b4f045 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -26,6 +26,7 @@ #include "td/telegram/BusinessConnectionId.h" #include "td/telegram/BusinessConnectionManager.h" #include "td/telegram/BusinessGreetingMessage.h" +#include "td/telegram/BusinessIntro.h" #include "td/telegram/BusinessManager.h" #include "td/telegram/BusinessWorkHours.h" #include "td/telegram/CallbackQueriesManager.h" @@ -7881,6 +7882,12 @@ void Td::on_request(uint64 id, td_api::setBusinessAwayMessageSettings &request) std::move(promise)); } +void Td::on_request(uint64 id, td_api::setBusinessIntro &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + business_manager_->set_business_intro(BusinessIntro(this, std::move(request.intro_)), std::move(promise)); +} + void Td::on_request(uint64 id, td_api::setProfilePhoto &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index ceae25e79..2944e84e0 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1410,6 +1410,8 @@ class Td final : public Actor { void on_request(uint64 id, td_api::setBusinessAwayMessageSettings &request); + void on_request(uint64 id, td_api::setBusinessIntro &request); + void on_request(uint64 id, td_api::setProfilePhoto &request); void on_request(uint64 id, const td_api::deleteProfilePhoto &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 6a2c2db88..95b8c65e5 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -6062,6 +6062,17 @@ class CliClient final : public Actor { td_api::make_object(shortcut_id, as_business_recipients(chat_ids), std::move(schedule_object), op == "sbamso"))); } + } else if (op == "sbi") { + string title; + string message; + string sticker; + get_args(args, title, message, sticker); + if (title.empty()) { + send_request(td_api::make_object(nullptr)); + } else { + send_request(td_api::make_object( + td_api::make_object(title, message, as_input_file(sticker)))); + } } else if (op == "gbcb") { send_request(td_api::make_object()); } else if (op == "sbcb") { @@ -6139,7 +6150,7 @@ class CliClient final : public Actor { send_request(td_api::make_object(bot_user_id, language_code)); send_request(td_api::make_object(bot_user_id, language_code)); send_request(td_api::make_object(bot_user_id, language_code)); - } else if (op == "sbi") { + } else if (op == "sbit") { UserId bot_user_id; string language_code; string name;