Add td_api::setBusinessIntro.

This commit is contained in:
levlam 2024-03-19 14:52:52 +03:00
parent e774ddab6e
commit 188a165938
7 changed files with 74 additions and 1 deletions

View File

@ -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 //@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; 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 //@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 //@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 //@settings Settings for the authentication of the user's phone number; pass null to use default settings

View File

@ -7,6 +7,7 @@
#include "td/telegram/BusinessIntro.h" #include "td/telegram/BusinessIntro.h"
#include "td/telegram/files/FileManager.h" #include "td/telegram/files/FileManager.h"
#include "td/telegram/misc.h"
#include "td/telegram/StickersManager.h" #include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
@ -16,6 +17,12 @@ BusinessIntro::BusinessIntro(Td *td, telegram_api::object_ptr<telegram_api::busi
if (intro == nullptr) { if (intro == nullptr) {
return; return;
} }
if (!clean_input_string(intro->title_)) {
intro->title_.clear();
}
if (!clean_input_string(intro->description_)) {
intro->description_.clear();
}
title_ = std::move(intro->title_); title_ = std::move(intro->title_);
description_ = std::move(intro->description_); description_ = std::move(intro->description_);
sticker_file_id_ = sticker_file_id_ =

View File

@ -9,6 +9,7 @@
#include "td/telegram/BusinessAwayMessage.h" #include "td/telegram/BusinessAwayMessage.h"
#include "td/telegram/BusinessConnectedBot.h" #include "td/telegram/BusinessConnectedBot.h"
#include "td/telegram/BusinessGreetingMessage.h" #include "td/telegram/BusinessGreetingMessage.h"
#include "td/telegram/BusinessIntro.h"
#include "td/telegram/BusinessRecipients.h" #include "td/telegram/BusinessRecipients.h"
#include "td/telegram/BusinessWorkHours.h" #include "td/telegram/BusinessWorkHours.h"
#include "td/telegram/ContactsManager.h" #include "td/telegram/ContactsManager.h"
@ -249,6 +250,41 @@ class UpdateBusinessAwayMessageQuery final : public Td::ResultHandler {
} }
}; };
class UpdateBusinessIntroQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
BusinessIntro intro_;
public:
explicit UpdateBusinessIntroQuery(Promise<Unit> &&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<telegram_api::account_updateBusinessIntro>(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)) { 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<UpdateBusinessAwayMessageQuery>(std::move(promise))->send(std::move(away_message)); td_->create_handler<UpdateBusinessAwayMessageQuery>(std::move(promise))->send(std::move(away_message));
} }
void BusinessManager::set_business_intro(BusinessIntro &&intro, Promise<Unit> &&promise) {
td_->create_handler<UpdateBusinessIntroQuery>(std::move(promise))->send(std::move(intro));
}
} // namespace td } // namespace td

View File

@ -18,6 +18,7 @@ namespace td {
class BusinessAwayMessage; class BusinessAwayMessage;
class BusinessGreetingMessage; class BusinessGreetingMessage;
class BusinessIntro;
class BusinessWorkHours; class BusinessWorkHours;
class DialogLocation; class DialogLocation;
class Td; class Td;
@ -40,6 +41,8 @@ class BusinessManager final : public Actor {
void set_business_away_message(BusinessAwayMessage &&away_message, Promise<Unit> &&promise); void set_business_away_message(BusinessAwayMessage &&away_message, Promise<Unit> &&promise);
void set_business_intro(BusinessIntro &&intro, Promise<Unit> &&promise);
private: private:
void tear_down() final; void tear_down() final;

View File

@ -26,6 +26,7 @@
#include "td/telegram/BusinessConnectionId.h" #include "td/telegram/BusinessConnectionId.h"
#include "td/telegram/BusinessConnectionManager.h" #include "td/telegram/BusinessConnectionManager.h"
#include "td/telegram/BusinessGreetingMessage.h" #include "td/telegram/BusinessGreetingMessage.h"
#include "td/telegram/BusinessIntro.h"
#include "td/telegram/BusinessManager.h" #include "td/telegram/BusinessManager.h"
#include "td/telegram/BusinessWorkHours.h" #include "td/telegram/BusinessWorkHours.h"
#include "td/telegram/CallbackQueriesManager.h" #include "td/telegram/CallbackQueriesManager.h"
@ -7881,6 +7882,12 @@ void Td::on_request(uint64 id, td_api::setBusinessAwayMessageSettings &request)
std::move(promise)); 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) { void Td::on_request(uint64 id, td_api::setProfilePhoto &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();

View File

@ -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::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, td_api::setProfilePhoto &request);
void on_request(uint64 id, const td_api::deleteProfilePhoto &request); void on_request(uint64 id, const td_api::deleteProfilePhoto &request);

View File

@ -6062,6 +6062,17 @@ class CliClient final : public Actor {
td_api::make_object<td_api::businessAwayMessageSettings>(shortcut_id, as_business_recipients(chat_ids), td_api::make_object<td_api::businessAwayMessageSettings>(shortcut_id, as_business_recipients(chat_ids),
std::move(schedule_object), op == "sbamso"))); 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<td_api::setBusinessIntro>(nullptr));
} else {
send_request(td_api::make_object<td_api::setBusinessIntro>(
td_api::make_object<td_api::inputBusinessIntro>(title, message, as_input_file(sticker))));
}
} else if (op == "gbcb") { } else if (op == "gbcb") {
send_request(td_api::make_object<td_api::getBusinessConnectedBot>()); send_request(td_api::make_object<td_api::getBusinessConnectedBot>());
} else if (op == "sbcb") { } else if (op == "sbcb") {
@ -6139,7 +6150,7 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::getBotName>(bot_user_id, language_code)); send_request(td_api::make_object<td_api::getBotName>(bot_user_id, language_code));
send_request(td_api::make_object<td_api::getBotInfoDescription>(bot_user_id, language_code)); send_request(td_api::make_object<td_api::getBotInfoDescription>(bot_user_id, language_code));
send_request(td_api::make_object<td_api::getBotInfoShortDescription>(bot_user_id, language_code)); send_request(td_api::make_object<td_api::getBotInfoShortDescription>(bot_user_id, language_code));
} else if (op == "sbi") { } else if (op == "sbit") {
UserId bot_user_id; UserId bot_user_id;
string language_code; string language_code;
string name; string name;