Add "forum_member_count_min" option.

This commit is contained in:
levlam 2022-11-05 02:43:23 +03:00
parent bf6a2723ef
commit e4fe474d58
3 changed files with 14 additions and 1 deletions

View File

@ -6424,7 +6424,7 @@ toggleSupergroupJoinByRequest supergroup_id:int53 join_by_request:Bool = Ok;
//@description Toggles whether the message history of a supergroup is available to new members; requires can_change_info administrator right @supergroup_id The identifier of the supergroup @is_all_history_available The new value of is_all_history_available
toggleSupergroupIsAllHistoryAvailable supergroup_id:int53 is_all_history_available:Bool = Ok;
//@description Toggles whether the supergroup is a forum; requires owner privileges in the supergroup @supergroup_id Identifier of the supergroup @is_forum New value of is_forum
//@description Toggles whether the supergroup is a forum; requires owner privileges in the supergroup @supergroup_id Identifier of the supergroup @is_forum New value of is_forum. A supergroup can be converted to a forum, only if it has at least GetOption("forum_member_count_min") members
toggleSupergroupIsForum supergroup_id:int53 is_forum:Bool = Ok;
//@description Upgrades supergroup to a broadcast group; requires owner privileges in the supergroup @supergroup_id Identifier of the supergroup

View File

@ -1491,6 +1491,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
bool is_premium_available = false;
int32 stickers_premium_by_emoji_num = 0;
int32 stickers_normal_by_emoji_per_premium_num = 2;
int32 forum_upgrade_participants_min = 200;
if (config->get_id() == telegram_api::jsonObject::ID) {
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
Slice key = key_value->key_;
@ -1843,6 +1844,10 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
G()->set_option_integer(key, setting_value);
continue;
}
if (key == "forum_upgrade_participants_min") {
forum_upgrade_participants_min = get_json_value_int(std::move(key_value->value_), key);
continue;
}
new_values.push_back(std::move(key_value));
}
@ -1929,6 +1934,11 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
} else {
options.set_option_integer("reactions_uniq_max", reactions_uniq_max);
}
if (forum_upgrade_participants_min < 0) {
options.set_option_empty("forum_member_count_min");
} else {
options.set_option_integer("forum_member_count_min", forum_upgrade_participants_min);
}
bool is_premium = options.get_option_boolean("is_premium");

View File

@ -116,6 +116,9 @@ OptionManager::OptionManager(Td *td)
G()->is_test_dc() ? static_cast<int64>(2964141614563343) : static_cast<int64>(773947703670341676);
set_option_integer("themed_emoji_statuses_sticker_set_id", sticker_set_id);
}
if (!have_option("forum_member_count_min")) {
set_option_integer("forum_member_count_min", 200);
}
}
OptionManager::~OptionManager() = default;