Add and use "chat_filter_count_max" option.

This commit is contained in:
levlam 2022-05-23 18:26:54 +03:00
parent d87cd52b68
commit e336819ac8
5 changed files with 12 additions and 3 deletions

View File

@ -5205,7 +5205,7 @@ addChatToList chat_id:int53 chat_list:ChatList = Ok;
//@description Returns information about a chat filter by its identifier @chat_filter_id Chat filter identifier //@description Returns information about a chat filter by its identifier @chat_filter_id Chat filter identifier
getChatFilter chat_filter_id:int32 = ChatFilter; getChatFilter chat_filter_id:int32 = ChatFilter;
//@description Creates new chat filter. Returns information about the created chat filter @filter Chat filter //@description Creates new chat filter. Returns information about the created chat filter. User can have up to GetOption("chat_filter_count_max") chat filters, but can increase the number with Teegram Premium @filter Chat filter
createChatFilter filter:chatFilter = ChatFilterInfo; createChatFilter filter:chatFilter = ChatFilterInfo;
//@description Edits existing chat filter. Returns information about the edited chat filter @chat_filter_id Chat filter identifier @filter The edited chat filter //@description Edits existing chat filter. Returns information about the edited chat filter @chat_filter_id Chat filter identifier @filter The edited chat filter

View File

@ -1964,6 +1964,12 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
shared_config.set_option_integer("reactions_uniq_max", reactions_uniq_max); shared_config.set_option_integer("reactions_uniq_max", reactions_uniq_max);
} }
bool is_premium = shared_config.get_option_boolean("is_premium");
auto chat_filter_count_max = shared_config.get_option_integer(
is_premium ? Slice("dialog_filters_limit_premium") : Slice("dialog_filters_limit_default"), is_premium ? 20 : 10);
shared_config.set_option_integer("chat_filter_count_max", static_cast<int32>(chat_filter_count_max));
shared_config.set_option_string("premium_features", implode(premium_features, ',')); shared_config.set_option_string("premium_features", implode(premium_features, ','));
shared_config.set_option_empty("default_ton_blockchain_config"); shared_config.set_option_empty("default_ton_blockchain_config");

View File

@ -19069,7 +19069,8 @@ Result<unique_ptr<DialogFilter>> MessagesManager::create_dialog_filter(DialogFil
void MessagesManager::create_dialog_filter(td_api::object_ptr<td_api::chatFilter> filter, void MessagesManager::create_dialog_filter(td_api::object_ptr<td_api::chatFilter> filter,
Promise<td_api::object_ptr<td_api::chatFilterInfo>> &&promise) { Promise<td_api::object_ptr<td_api::chatFilterInfo>> &&promise) {
CHECK(!td_->auth_manager_->is_bot()); CHECK(!td_->auth_manager_->is_bot());
if (dialog_filters_.size() >= MAX_DIALOG_FILTERS) { auto max_dialog_filters = G()->shared_config().get_option_integer("chat_filter_count_max");
if (dialog_filters_.size() >= max_dialog_filters) {
return promise.set_error(Status::Error(400, "The maximum number of chat folders exceeded")); return promise.set_error(Status::Error(400, "The maximum number of chat folders exceeded"));
} }
if (!is_update_chat_filters_sent_) { if (!is_update_chat_filters_sent_) {

View File

@ -1757,7 +1757,6 @@ class MessagesManager final : public Actor {
static constexpr size_t MAX_DESCRIPTION_LENGTH = 255; // server side limit for chat description static constexpr size_t MAX_DESCRIPTION_LENGTH = 255; // server side limit for chat description
static constexpr size_t MAX_DIALOG_FILTER_TITLE_LENGTH = 12; // server side limit for dialog filter title static constexpr size_t MAX_DIALOG_FILTER_TITLE_LENGTH = 12; // server side limit for dialog filter title
static constexpr int32 MAX_PRIVATE_MESSAGE_TTL = 60; // server side limit static constexpr int32 MAX_PRIVATE_MESSAGE_TTL = 60; // server side limit
static constexpr int32 MAX_DIALOG_FILTERS = 10; // server side limit
static constexpr int32 DIALOG_FILTERS_CACHE_TIME = 86400; static constexpr int32 DIALOG_FILTERS_CACHE_TIME = 86400;
static constexpr int64 SPONSORED_DIALOG_ORDER = static_cast<int64>(2147483647) << 32; static constexpr int64 SPONSORED_DIALOG_ORDER = static_cast<int64>(2147483647) << 32;

View File

@ -111,6 +111,9 @@ OptionManager::OptionManager(Td *td, ActorShared<> parent) : td_(td), parent_(st
if (!G()->shared_config().have_option("notification_sound_count_max")) { if (!G()->shared_config().have_option("notification_sound_count_max")) {
G()->shared_config().set_option_integer("notification_sound_count_max", G()->is_test_dc() ? 5 : 100); G()->shared_config().set_option_integer("notification_sound_count_max", G()->is_test_dc() ? 5 : 100);
} }
if (!G()->shared_config().have_option("chat_filter_count_max")) {
G()->shared_config().set_option_integer("chat_filter_count_max", G()->is_test_dc() ? 3 : 10);
}
G()->shared_config().set_option_integer("utc_time_offset", Clocks::tz_offset()); G()->shared_config().set_option_integer("utc_time_offset", Clocks::tz_offset());
} }