Add option "chat_filter_chosen_chat_count_max".

This commit is contained in:
levlam 2022-05-23 20:04:36 +03:00
parent c584b48c10
commit d986c9bc27
6 changed files with 19 additions and 8 deletions

View File

@ -974,9 +974,9 @@ chatTypeSecret secret_chat_id:int32 user_id:int53 = ChatType;
//@title The title of the filter; 1-12 characters without line feeds
//@icon_name The chosen icon name for short filter representation. If non-empty, must be one of "All", "Unread", "Unmuted", "Bots", "Channels", "Groups", "Private", "Custom", "Setup", "Cat", "Crown", "Favorite", "Flower", "Game", "Home", "Love", "Mask", "Party", "Sport", "Study", "Trade", "Travel", "Work".
//-If empty, use getChatFilterDefaultIconName to get default icon name for the filter
//@pinned_chat_ids The chat identifiers of pinned chats in the filtered chat list
//@included_chat_ids The chat identifiers of always included chats in the filtered chat list
//@excluded_chat_ids The chat identifiers of always excluded chats in the filtered chat list
//@pinned_chat_ids The chat identifiers of pinned chats in the filtered chat list. There can be up to GetOption("chat_filter_chosen_chat_count_max") pinned and always included non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
//@included_chat_ids The chat identifiers of always included chats in the filtered chat list. There can be up to GetOption("chat_filter_chosen_chat_count_max") pinned and always included non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
//@excluded_chat_ids The chat identifiers of always excluded chats in the filtered chat list. There can be up to GetOption("chat_filter_chosen_chat_count_max") always excluded non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
//@exclude_muted True, if muted chats need to be excluded
//@exclude_read True, if read chats need to be excluded
//@exclude_archived True, if archived chats need to be excluded
@ -2892,7 +2892,7 @@ premiumLimitTypeFavoriteStickerCount = PremiumLimitType;
premiumLimitTypeChatFilterCount = PremiumLimitType;
//@description The maximum number of pinned and always included, or always excluded chats in a chat list
premiumLimitTypeChatFilterSpecificChatCount = PremiumLimitType;
premiumLimitTypeChatFilterChosenChatCount = PremiumLimitType;
//@description The maximum number of pinned chats in the main chat list
premiumLimitTypePinnedChatCount = PremiumLimitType;

View File

@ -1209,7 +1209,7 @@ void ConfigManager::get_premium_features(Promise<td_api::object_ptr<td_api::prem
return td_api::make_object<td_api::premiumLimitTypeChatFilterCount>();
}
if (key == "dialog_filters_chats_limit") {
return td_api::make_object<td_api::premiumLimitTypeChatFilterSpecificChatCount>();
return td_api::make_object<td_api::premiumLimitTypeChatFilterChosenChatCount>();
}
if (key == "dialogs_pinned_limit") {
return td_api::make_object<td_api::premiumLimitTypePinnedChatCount>();
@ -1970,6 +1970,12 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
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));
auto chat_filter_chosen_chat_count_max = shared_config.get_option_integer(
is_premium ? Slice("dialog_filters_chats_limit_premium") : Slice("dialog_filters_chats_limit_default"),
is_premium ? 200 : 100);
shared_config.set_option_integer("chat_filter_chosen_chat_count_max",
static_cast<int32>(chat_filter_chosen_chat_count_max));
shared_config.set_option_string("premium_features", implode(premium_features, ','));
shared_config.set_option_empty("default_ton_blockchain_config");

View File

@ -6,18 +6,21 @@
//
#include "td/telegram/DialogFilter.h"
#include "td/telegram/ConfigShared.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/Global.h"
#include "td/utils/algorithm.h"
#include "td/utils/emoji.h"
#include "td/utils/FlatHashSet.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
namespace td {
int32 DialogFilter::get_max_filter_dialogs() {
return 100; // server side limit
return narrow_cast<int32>(G()->shared_config().get_option_integer("chat_filter_chosen_chat_count_max", 100));
}
unique_ptr<DialogFilter> DialogFilter::get_dialog_filter(

View File

@ -8,7 +8,6 @@
#include "td/telegram/ConfigShared.h"
#include "td/telegram/net/ConnectionCreator.h"
#include "td/telegram/net/MtprotoHeader.h"
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/net/TempAuthKeyWatchdog.h"
#include "td/telegram/OptionManager.h"

View File

@ -8,6 +8,7 @@
#include "td/telegram/DhConfig.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/MtprotoHeader.h"
#include "td/telegram/net/NetQueryCreator.h"
#include "td/telegram/TdParameters.h"
@ -45,7 +46,6 @@ class GroupCallManager;
class LanguagePackManager;
class LinkManager;
class MessagesManager;
class MtprotoHeader;
class NetQueryDispatcher;
class NotificationManager;
class NotificationSettingsManager;

View File

@ -114,6 +114,9 @@ OptionManager::OptionManager(Td *td, ActorShared<> parent) : td_(td), parent_(st
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);
}
if (!G()->shared_config().have_option("chat_filter_chosen_chat_count_max")) {
G()->shared_config().set_option_integer("chat_filter_chosen_chat_count_max", G()->is_test_dc() ? 5 : 100);
}
G()->shared_config().set_option_integer("utc_time_offset", Clocks::tz_offset());
}