Add td_api::getChatBoostStatus.
This commit is contained in:
parent
0ab5ab00ea
commit
7605812d2c
@ -3352,6 +3352,17 @@ storyInfo story_id:int32 date:int32 is_for_close_friends:Bool = StoryInfo;
|
||||
chatActiveStories chat_id:int53 list:StoryList order:int53 max_read_story_id:int32 stories:vector<storyInfo> = ChatActiveStories;
|
||||
|
||||
|
||||
//@description Describes current boost status of a chat
|
||||
//@is_boosted True, if the current user has already boosted the chat
|
||||
//@level Current boost level of the chat
|
||||
//@boost_count The number of times the chat was boosted
|
||||
//@current_level_boost_count The number of boosts added to reach the current level
|
||||
//@next_level_boost_count The number of boosts needed to reach the next level; 0 if the next level isn't available
|
||||
//@premium_member_count Approximate number of Telegram Premium subscribers joined the chat; always 0 if the current user isn't an administrator in the chat
|
||||
//@premium_member_percentage A percentage of Telegram Premium subscribers joined the chat; always 0 if the current user isn't an administrator in the chat
|
||||
chatBoostStatus is_boosted:Bool level:int32 boost_count:int32 current_level_boost_count:int32 next_level_boost_count:int32 premium_member_count:int32 premium_member_percentage:double = ChatBoostStatus;
|
||||
|
||||
|
||||
//@class CallDiscardReason @description Describes the reason why a call was discarded
|
||||
|
||||
//@description The call wasn't discarded, or the reason is unknown
|
||||
@ -7639,6 +7650,10 @@ reportStory story_sender_chat_id:int53 story_id:int32 reason:ReportReason text:s
|
||||
activateStoryStealthMode = Ok;
|
||||
|
||||
|
||||
//@description Returns the current boost status for a channel chat @chat_id The identifier of the channel chat
|
||||
getChatBoostStatus chat_id:int53 = ChatBoostStatus;
|
||||
|
||||
|
||||
//@description Returns information about a bot that can be added to attachment or side menu @bot_user_id Bot's user identifier
|
||||
getAttachmentMenuBot bot_user_id:int53 = AttachmentMenuBot;
|
||||
|
||||
|
@ -739,6 +739,68 @@ class ActivateStealthModeQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetBoostsStatusQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::chatBoostStatus>> promise_;
|
||||
DialogId dialog_id_;
|
||||
|
||||
public:
|
||||
explicit GetBoostsStatusQuery(Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id) {
|
||||
dialog_id_ = dialog_id;
|
||||
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
|
||||
CHECK(input_peer != nullptr);
|
||||
send_query(
|
||||
G()->net_query_creator().create(telegram_api::stories_getBoostsStatus(std::move(input_peer)), {{dialog_id}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::stories_getBoostsStatus>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(DEBUG) << "Receive result for GetBoostsStatusQuery: " << to_string(result);
|
||||
if (result->level_ < 0 || result->current_level_boosts_ < 0 || result->boosts_ < result->current_level_boosts_ ||
|
||||
(result->next_level_boosts_ != 0 && result->boosts_ >= result->next_level_boosts_)) {
|
||||
LOG(ERROR) << "Receive invalid " << to_string(result);
|
||||
if (result->level_ < 0) {
|
||||
result->level_ = 0;
|
||||
}
|
||||
if (result->current_level_boosts_ < 0) {
|
||||
result->current_level_boosts_ = 0;
|
||||
}
|
||||
if (result->boosts_ < result->current_level_boosts_) {
|
||||
result->boosts_ = result->current_level_boosts_;
|
||||
}
|
||||
if (result->next_level_boosts_ != 0 && result->boosts_ >= result->next_level_boosts_) {
|
||||
result->next_level_boosts_ = result->boosts_ + 1;
|
||||
}
|
||||
}
|
||||
int32 premium_member_count = 0;
|
||||
double premium_member_percentage = 0.0;
|
||||
if (result->premium_audience_ != nullptr) {
|
||||
auto part = static_cast<int32>(result->premium_audience_->part_);
|
||||
auto total = static_cast<int32>(result->premium_audience_->total_);
|
||||
premium_member_count = max(0, part);
|
||||
if (result->premium_audience_->total_ > 0) {
|
||||
premium_member_percentage = 100.0 * premium_member_count / max(total, premium_member_count);
|
||||
}
|
||||
}
|
||||
promise_.set_value(td_api::make_object<td_api::chatBoostStatus>(
|
||||
result->my_boost_, result->level_, result->boosts_, result->current_level_boosts_, result->next_level_boosts_,
|
||||
premium_member_count, premium_member_percentage));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBoostsStatusQuery");
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class CanSendStoryQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::CanSendStoryResult>> promise_;
|
||||
DialogId dialog_id_;
|
||||
@ -2733,6 +2795,18 @@ void StoryManager::activate_stealth_mode(Promise<Unit> &&promise) {
|
||||
td_->create_handler<ActivateStealthModeQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
void StoryManager::get_dialog_boost_status(DialogId dialog_id,
|
||||
Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise) {
|
||||
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
td_->create_handler<GetBoostsStatusQuery>(std::move(promise))->send(dialog_id);
|
||||
}
|
||||
|
||||
bool StoryManager::have_story(StoryFullId story_full_id) const {
|
||||
return get_story(story_full_id) != nullptr;
|
||||
}
|
||||
|
@ -258,6 +258,8 @@ class StoryManager final : public Actor {
|
||||
|
||||
void activate_stealth_mode(Promise<Unit> &&promise);
|
||||
|
||||
void get_dialog_boost_status(DialogId dialog_id, Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise);
|
||||
|
||||
void remove_story_notifications_by_story_ids(DialogId dialog_id, const vector<StoryId> &story_ids);
|
||||
|
||||
StoryId on_get_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::StoryItem> &&story_item_ptr);
|
||||
|
@ -6580,6 +6580,12 @@ void Td::on_request(uint64 id, const td_api::activateStoryStealthMode &request)
|
||||
story_manager_->activate_stealth_mode(std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getChatBoostStatus &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
story_manager_->get_dialog_boost_status(DialogId(request.chat_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getAttachmentMenuBot &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -1038,6 +1038,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::activateStoryStealthMode &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getChatBoostStatus &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getAttachmentMenuBot &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::toggleBotIsAddedToAttachmentMenu &request);
|
||||
|
@ -4288,6 +4288,10 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::reportStory>(story_sender_chat_id, story_id, reason, text));
|
||||
} else if (op == "assm") {
|
||||
send_request(td_api::make_object<td_api::activateStoryStealthMode>());
|
||||
} else if (op == "gcbs") {
|
||||
ChatId chat_id;
|
||||
get_args(args, chat_id);
|
||||
send_request(td_api::make_object<td_api::getChatBoostStatus>(chat_id));
|
||||
} else if (op == "gamb") {
|
||||
UserId user_id;
|
||||
get_args(args, user_id);
|
||||
|
Loading…
Reference in New Issue
Block a user