Improve td_api::chatBoost.
This commit is contained in:
parent
43e210dbc8
commit
8d25f6f1d9
@ -3484,6 +3484,25 @@ 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;
|
||||
|
||||
|
||||
//@class ChatBoostSource @description Describes source of a chat boost
|
||||
|
||||
//@description The chat created a Telegram Premium gift code for a user
|
||||
//@user_id Identifier of a user, for which the gift code was created
|
||||
//@gift_code The created Telegram Premium gift code, which is known only if this is a gift code for the current user, or it has already been claimed
|
||||
chatBoostSourceGiftCode user_id:int53 gift_code:string = ChatBoostSource;
|
||||
|
||||
//@description The chat created a Telegram Premium giveaway
|
||||
//@user_id Identifier of a user that won in the giveaway; 0 if none
|
||||
//@gift_code The created Telegram Premium gift code used by the user; or an empty string if none
|
||||
//@giveaway_message_id Identifier of the corresponding giveaway message; can be an identifier of a deleted message
|
||||
//@is_unclaimed True, if the winner for the corresponding Premium subscription wasn't chosen
|
||||
chatBoostSourceGiveaway user_id:int53 gift_code:string giveaway_message_id:int53 is_unclaimed:Bool = ChatBoostSource;
|
||||
|
||||
//@description A user with Telegram Premium subscription or gifted Telegram Premium boosted the chat
|
||||
//@user_id Identifier of the user
|
||||
chatBoostSourcePremium user_id:int53 = ChatBoostSource;
|
||||
|
||||
|
||||
//@description Describes a prepaid Telegram Premium giveaway
|
||||
//@id Unique identifier of the prepaid giveaway
|
||||
//@user_count Number of users which will receive Telegram Premium subscription gift codes
|
||||
@ -3503,8 +3522,12 @@ prepaidPremiumGiveaway id:int64 user_count:int32 month_count:int32 payment_date:
|
||||
//@prepaid_giveaways The list of prepaid giveaways available for the chat; only for chat administrators
|
||||
chatBoostStatus boost_url:string 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 prepaid_giveaways:vector<prepaidPremiumGiveaway> = ChatBoostStatus;
|
||||
|
||||
//@description Describes a boost of a chat @user_id Identifier of a user that boosted the chat @expiration_date Point in time (Unix timestamp) when the boost will automatically expire if the user will not prolongate their Telegram Premium subscription
|
||||
chatBoost user_id:int53 expiration_date:int32 = ChatBoost;
|
||||
//@description Describes a boost of a chat
|
||||
//@count The number of boosts applied
|
||||
//@source Source of the boost
|
||||
//@start_date Point in time (Unix timestamp) when the boost was added
|
||||
//@expiration_date Point in time (Unix timestamp) when the boost will expire
|
||||
chatBoost count:int32 source:ChatBoostSource start_date:int32 expiration_date:int32 = ChatBoost;
|
||||
|
||||
//@description Contains a list of boosts applied to a chat @total_count Total number of boosts applied to the chat @boosts List of boosts @next_offset The offset for the next request. If empty, there are no more results
|
||||
foundChatBoosts total_count:int32 boosts:vector<chatBoost> next_offset:string = FoundChatBoosts;
|
||||
|
@ -147,17 +147,47 @@ class GetBoostsListQuery final : public Td::ResultHandler {
|
||||
|
||||
auto total_count = result->count_;
|
||||
vector<td_api::object_ptr<td_api::chatBoost>> boosts;
|
||||
for (auto &booster : result->boosts_) {
|
||||
UserId user_id(booster->user_id_);
|
||||
if (!user_id.is_valid()) {
|
||||
for (auto &boost : result->boosts_) {
|
||||
auto source = [&]() -> td_api::object_ptr<td_api::ChatBoostSource> {
|
||||
if (boost->giveaway_) {
|
||||
UserId user_id(boost->user_id_);
|
||||
if (!user_id.is_valid()) {
|
||||
user_id = UserId();
|
||||
}
|
||||
auto giveaway_message_id = MessageId(ServerMessageId(boost->giveaway_msg_id_));
|
||||
if (!giveaway_message_id.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatBoostSourceGiveaway>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "chatBoostSourceGiveaway"), boost->used_gift_slug_,
|
||||
giveaway_message_id.get(), boost->unclaimed_);
|
||||
}
|
||||
if (boost->gift_) {
|
||||
UserId user_id(boost->user_id_);
|
||||
if (!user_id.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatBoostSourceGiftCode>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "chatBoostSourceGiftCode"), boost->used_gift_slug_);
|
||||
}
|
||||
|
||||
UserId user_id(boost->user_id_);
|
||||
if (!user_id.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::chatBoostSourcePremium>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "chatBoostSourcePremium"));
|
||||
}();
|
||||
if (source == nullptr) {
|
||||
LOG(ERROR) << "Receive " << to_string(boost);
|
||||
continue;
|
||||
}
|
||||
auto expire_date = booster->expires_;
|
||||
if (expire_date <= G()->unix_time()) {
|
||||
auto expiration_date = boost->expires_;
|
||||
if (expiration_date <= G()->unix_time()) {
|
||||
continue;
|
||||
}
|
||||
boosts.push_back(td_api::make_object<td_api::chatBoost>(
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "chatBoost"), expire_date));
|
||||
boosts.push_back(td_api::make_object<td_api::chatBoost>(max(boost->multiplier_, 1), std::move(source),
|
||||
boost->date_, expiration_date));
|
||||
}
|
||||
promise_.set_value(
|
||||
td_api::make_object<td_api::foundChatBoosts>(total_count, std::move(boosts), result->next_offset_));
|
||||
|
Loading…
Reference in New Issue
Block a user