Improve getChatBoostFeatures.
This commit is contained in:
parent
023ee09714
commit
a784e6fe14
@ -9016,7 +9016,7 @@ getStoryPublicForwards story_sender_chat_id:int53 story_id:int32 offset:string l
|
||||
//@level Chat boost level
|
||||
getChatBoostLevelFeatures is_channel:Bool level:int32 = ChatBoostLevelFeatures;
|
||||
|
||||
//@description Returns list of features available on the first 10 chat boost levels; this is an offline request
|
||||
//@description Returns list of features available for different chat boost levels; this is an offline request
|
||||
//@is_channel Pass true to get the list of features for channels; pass false to get the list of features for supergroups
|
||||
getChatBoostFeatures is_channel:Bool = ChatBoostFeatures;
|
||||
|
||||
|
@ -371,19 +371,27 @@ td_api::object_ptr<td_api::chatBoostLevelFeatures> BoostManager::get_chat_boost_
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chatBoostFeatures> BoostManager::get_chat_boost_features_object(bool for_megagroup) const {
|
||||
vector<td_api::object_ptr<td_api::chatBoostLevelFeatures>> features;
|
||||
for (int32 level = 1; level <= 10; level++) {
|
||||
features.push_back(get_chat_boost_level_features_object(for_megagroup, level));
|
||||
}
|
||||
std::set<int32> big_levels;
|
||||
auto get_min_boost_level = [&](Slice name) {
|
||||
return narrow_cast<int32>(td_->option_manager_->get_option_integer(
|
||||
auto min_level = narrow_cast<int32>(td_->option_manager_->get_option_integer(
|
||||
PSLICE() << (for_megagroup ? "group" : "channel") << '_' << name << "_level_min", 1000000000));
|
||||
if (min_level > 10 && min_level < 1000000) {
|
||||
big_levels.insert(min_level);
|
||||
}
|
||||
return min_level;
|
||||
};
|
||||
return td_api::make_object<td_api::chatBoostFeatures>(
|
||||
std::move(features), get_min_boost_level("profile_bg_icon"), get_min_boost_level("bg_icon"),
|
||||
auto result = td_api::make_object<td_api::chatBoostFeatures>(
|
||||
Auto(), get_min_boost_level("profile_bg_icon"), get_min_boost_level("bg_icon"),
|
||||
get_min_boost_level("emoji_status"), get_min_boost_level("wallpaper"), get_min_boost_level("custom_wallpaper"),
|
||||
get_min_boost_level("emoji_stickers"), get_min_boost_level("transcribe"),
|
||||
get_min_boost_level("restrict_sponsored"));
|
||||
for (int32 level = 1; level <= 10; level++) {
|
||||
result->features_.push_back(get_chat_boost_level_features_object(for_megagroup, level));
|
||||
}
|
||||
for (auto level : big_levels) {
|
||||
result->features_.push_back(get_chat_boost_level_features_object(for_megagroup, level));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void BoostManager::get_boost_slots(Promise<td_api::object_ptr<td_api::chatBoostSlots>> &&promise) {
|
||||
|
Loading…
Reference in New Issue
Block a user