diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0f30697a4..762d50b4d 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2303,7 +2303,7 @@ messageExtendedMediaUnsupported caption:formattedText = MessageExtendedMedia; //@additional_chat_ids Identifiers of other channel chats that must be subscribed by the users to be eligible for the giveaway. There can be up to getOption("giveaway_additional_chat_count_max") additional chats //@winners_selection_date Point in time (Unix timestamp) when the giveaway is expected to be performed; must be from 1 minute to 365 days in the future in scheduled giveaways //@only_new_subscribers True, if only new subscribers of the chats will be eligible for the giveaway -//@country_codes The list of two-letter ISO 3166-1 alpha-2 codes of countries, only users from which will be eligible for the giveaway +//@country_codes The list of two-letter ISO 3166-1 alpha-2 codes of countries, only users from which will be eligible for the giveaway. If empty, then all users can participate in the giveaway. There can be up to getOption("giveaway_country_count_max") chosen countries premiumGiveawayParameters boosted_chat_id:int53 additional_chat_ids:vector winners_selection_date:int32 only_new_subscribers:Bool country_codes:vector = PremiumGiveawayParameters; diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 19bce5a98..264ac14d7 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -1922,6 +1922,10 @@ void ConfigManager::process_app_config(tl_object_ptr &c get_json_value_int(std::move(key_value->value_), key)); continue; } + if (key == "giveaway_countries_max") { + G()->set_option_integer("giveaway_country_count_max", get_json_value_int(std::move(key_value->value_), key)); + continue; + } new_values.push_back(std::move(key_value)); } diff --git a/td/telegram/ConfigManager.h b/td/telegram/ConfigManager.h index 2598e0edb..dd03eb4a6 100644 --- a/td/telegram/ConfigManager.h +++ b/td/telegram/ConfigManager.h @@ -102,7 +102,7 @@ class ConfigManager final : public NetQueryCallback { private: struct AppConfig { - static constexpr int32 CURRENT_VERSION = 15; + static constexpr int32 CURRENT_VERSION = 16; int32 version_ = 0; int32 hash_ = 0; telegram_api::object_ptr config_; diff --git a/td/telegram/GiveawayParameters.cpp b/td/telegram/GiveawayParameters.cpp index 1bf40833e..6e2616257 100644 --- a/td/telegram/GiveawayParameters.cpp +++ b/td/telegram/GiveawayParameters.cpp @@ -56,6 +56,9 @@ Result GiveawayParameters::get_giveaway_parameters( return Status::Error(400, "Invalid country code specified"); } } + if (parameters->country_codes_.size() > td->option_manager_->get_option_integer("giveaway_country_count_max")) { + return Status::Error(400, "Too many countries specified"); + } return GiveawayParameters(boosted_channel_id, std::move(additional_channel_ids), parameters->only_new_subscribers_, parameters->winners_selection_date_, vector(parameters->country_codes_)); } diff --git a/td/telegram/OptionManager.cpp b/td/telegram/OptionManager.cpp index b19a001e8..3b0009caa 100644 --- a/td/telegram/OptionManager.cpp +++ b/td/telegram/OptionManager.cpp @@ -131,6 +131,9 @@ OptionManager::OptionManager(Td *td) if (!have_option("giveaway_additional_chat_count_max")) { set_option_integer("giveaway_additional_chat_count_max", G()->is_test_dc() ? 3 : 10); } + if (!have_option("giveaway_country_count_max")) { + set_option_integer("giveaway_country_count_max", G()->is_test_dc() ? 3 : 10); + } set_option_empty("archive_and_mute_new_chats_from_unknown_users"); set_option_empty("chat_filter_count_max");