Return ChatBoostSlots from boostChat.
This commit is contained in:
parent
4f4537ba33
commit
216b4833dd
@ -7937,8 +7937,8 @@ getAvailableChatBoostSlots = ChatBoostSlots;
|
||||
//@description Returns the current boost status for a channel chat @chat_id Identifier of the channel chat
|
||||
getChatBoostStatus chat_id:int53 = ChatBoostStatus;
|
||||
|
||||
//@description Boosts a chat @chat_id Identifier of the chat @slot_ids Identifiers of boost slots of the current user from which to apply boosts to the chat
|
||||
boostChat chat_id:int53 slot_ids:vector<int32> = Ok;
|
||||
//@description Boosts a chat and returns the list of available chat boost slots for the current user after the boost @chat_id Identifier of the chat @slot_ids Identifiers of boost slots of the current user from which to apply boosts to the chat
|
||||
boostChat chat_id:int53 slot_ids:vector<int32> = ChatBoostSlots;
|
||||
|
||||
//@description Returns an HTTPS link to boost the specified channel chat @chat_id Identifier of the chat
|
||||
getChatBoostLink chat_id:int53 = ChatBoostLink;
|
||||
|
@ -155,11 +155,12 @@ class GetBoostsStatusQuery final : public Td::ResultHandler {
|
||||
};
|
||||
|
||||
class ApplyBoostQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
Promise<td_api::object_ptr<td_api::chatBoostSlots>> promise_;
|
||||
DialogId dialog_id_;
|
||||
|
||||
public:
|
||||
explicit ApplyBoostQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
explicit ApplyBoostQuery(Promise<td_api::object_ptr<td_api::chatBoostSlots>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id, vector<int32> slot_ids) {
|
||||
@ -178,7 +179,9 @@ class ApplyBoostQuery final : public Td::ResultHandler {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
promise_.set_value(Unit());
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(DEBUG) << "Receive result for ApplyBoostQuery: " << to_string(result);
|
||||
promise_.set_value(get_chat_boost_slots_object(td_, std::move(result)));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
@ -295,7 +298,8 @@ void BoostManager::get_dialog_boost_status(DialogId dialog_id,
|
||||
td_->create_handler<GetBoostsStatusQuery>(std::move(promise))->send(dialog_id);
|
||||
}
|
||||
|
||||
void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids, Promise<Unit> &&promise) {
|
||||
void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids,
|
||||
Promise<td_api::object_ptr<td_api::chatBoostSlots>> &&promise) {
|
||||
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
@ -303,7 +307,7 @@ void BoostManager::boost_dialog(DialogId dialog_id, vector<int32> slot_ids, Prom
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
if (slot_ids.empty()) {
|
||||
return promise.set_value(Unit());
|
||||
return get_boost_slots(std::move(promise));
|
||||
}
|
||||
|
||||
td_->create_handler<ApplyBoostQuery>(std::move(promise))->send(dialog_id, slot_ids);
|
||||
|
@ -28,7 +28,8 @@ class BoostManager final : public Actor {
|
||||
|
||||
void get_dialog_boost_status(DialogId dialog_id, Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise);
|
||||
|
||||
void boost_dialog(DialogId dialog_id, vector<int32> slot_ids, Promise<Unit> &&promise);
|
||||
void boost_dialog(DialogId dialog_id, vector<int32> slot_ids,
|
||||
Promise<td_api::object_ptr<td_api::chatBoostSlots>> &&promise);
|
||||
|
||||
Result<std::pair<string, bool>> get_dialog_boost_link(DialogId dialog_id);
|
||||
|
||||
|
@ -6651,7 +6651,7 @@ void Td::on_request(uint64 id, const td_api::getChatBoostStatus &request) {
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::boostChat &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
boost_manager_->boost_dialog(DialogId(request.chat_id_), std::move(request.slot_ids_), std::move(promise));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user