Add td_api::getBusinessConnectedBot.
This commit is contained in:
parent
261a3d0c22
commit
d56025f609
@ -9405,6 +9405,10 @@ resendChangePhoneNumberCode = AuthenticationCodeInfo;
|
||||
checkChangePhoneNumberCode code:string = Ok;
|
||||
|
||||
|
||||
//@description Returns the business bot connected to the current user account. Returns a 404 error if there is no connected bot
|
||||
getBusinessConnectedBot = BusinessConnectedBot;
|
||||
|
||||
|
||||
//@description Returns an HTTPS link, which can be used to get information about the current user
|
||||
getUserLink = UserLink;
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "td/telegram/BusinessManager.h"
|
||||
|
||||
#include "td/telegram/BusinessAwayMessage.h"
|
||||
#include "td/telegram/BusinessConnectedBot.h"
|
||||
#include "td/telegram/BusinessGreetingMessage.h"
|
||||
#include "td/telegram/BusinessWorkHours.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
@ -20,6 +21,46 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class GetConnectedBotsQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::businessConnectedBot>> promise_;
|
||||
|
||||
public:
|
||||
explicit GetConnectedBotsQuery(Promise<td_api::object_ptr<td_api::businessConnectedBot>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send() {
|
||||
send_query(G()->net_query_creator().create(telegram_api::account_getConnectedBots(), {{"me"}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::account_getConnectedBots>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetConnectedBotsQuery: " << to_string(result);
|
||||
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetConnectedBotsQuery");
|
||||
if (result->connected_bots_.size() > 1u) {
|
||||
return on_error(Status::Error(500, "Receive invalid response"));
|
||||
}
|
||||
if (result->connected_bots_.empty()) {
|
||||
return promise_.set_value(nullptr);
|
||||
}
|
||||
auto bot = BusinessConnectedBot(std::move(result->connected_bots_[0]));
|
||||
if (!bot.is_valid()) {
|
||||
return on_error(Status::Error(500, "Receive invalid bot"));
|
||||
}
|
||||
promise_.set_value(bot.get_business_connected_bot_object(td_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class UpdateBusinessLocationQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
DialogLocation location_;
|
||||
@ -170,6 +211,10 @@ void BusinessManager::tear_down() {
|
||||
parent_.reset();
|
||||
}
|
||||
|
||||
void BusinessManager::get_business_connected_bot(Promise<td_api::object_ptr<td_api::businessConnectedBot>> &&promise) {
|
||||
td_->create_handler<GetConnectedBotsQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
void BusinessManager::set_business_location(DialogLocation &&location, Promise<Unit> &&promise) {
|
||||
td_->create_handler<UpdateBusinessLocationQuery>(std::move(promise))->send(std::move(location));
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/td_api.h"
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
@ -23,6 +25,8 @@ class BusinessManager final : public Actor {
|
||||
public:
|
||||
BusinessManager(Td *td, ActorShared<> parent);
|
||||
|
||||
void get_business_connected_bot(Promise<td_api::object_ptr<td_api::businessConnectedBot>> &&promise);
|
||||
|
||||
void set_business_location(DialogLocation &&location, Promise<Unit> &&promise);
|
||||
|
||||
void set_business_work_hours(BusinessWorkHours &&work_hours, Promise<Unit> &&promise);
|
||||
|
@ -7862,6 +7862,12 @@ void Td::on_request(uint64 id, const td_api::setProfileAccentColor &request) {
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getBusinessConnectedBot &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
business_manager_->get_business_connected_bot(std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setSupergroupUsername &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.username_);
|
||||
|
@ -1405,6 +1405,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::setProfileAccentColor &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getBusinessConnectedBot &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setSupergroupUsername &request);
|
||||
|
||||
void on_request(uint64 id, td_api::toggleSupergroupUsernameIsActive &request);
|
||||
|
@ -6020,6 +6020,8 @@ class CliClient final : public Actor {
|
||||
rand_bool(), rand_bool(), rand_bool()),
|
||||
std::move(schedule_object), op == "sbamso")));
|
||||
}
|
||||
} else if (op == "gbcb") {
|
||||
send_request(td_api::make_object<td_api::getBusinessConnectedBot>());
|
||||
} else if (op == "sco") {
|
||||
SearchQuery query;
|
||||
get_args(args, query);
|
||||
|
Loading…
Reference in New Issue
Block a user