diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index d521df904..6a68073a1 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2877,6 +2877,36 @@ languagePackInfo id:string base_language_pack_id:string name:string native_name: localizationTargetInfo language_packs:vector = LocalizationTargetInfo; +//@class PremiumLimitType @description Describes type of a limit, increased for Premium users + +//@description The maximum number of joined supergroups and channels +premiumLimitTypeSupergroupCount = PremiumLimitType; + +//@description The maximum number of saved animations +premiumLimitTypeSavedAnimationCount = PremiumLimitType; + +//@description The maximum number of favorite stickers +premiumLimitTypeFavoriteStickerCount = PremiumLimitType; + +//@description The maximum number of chat filters +premiumLimitTypeChatFilterCount = PremiumLimitType; + +//@description The maximum number of pinned and always included, or always excluded chats in a chat list +premiumLimitTypeChatFilterSpecificChatCount = PremiumLimitType; + +//@description The maximum number of pinned chats in the main chat list +premiumLimitTypePinnedChatCount = PremiumLimitType; + +//@description The maximum number of pinned chats in the archive chat list +premiumLimitTypePinnedArchivedChatCount = PremiumLimitType; + +//@description The maximum number of created public chats +premiumLimitTypeCreatedPublicChatCount = PremiumLimitType; + +//@description The maximum length of sent media caption +premiumLimitTypeCaptionLength = PremiumLimitType; + + //@class PremiumFeature @description Describes a feature available to Premium users //@description Increased limits @@ -2910,8 +2940,11 @@ premiumFeatureProfileBadge = PremiumFeature; premiumFeatureAnimatedProfilePhoto = PremiumFeature; -//@description Contains information about features, available to Premium users @features The list of available features -premiumFeatures features:vector = PremiumFeatures; +//@description Contains information about a limit, increased for Premium users @type The type of the limit @default_value Default value of the limit @premium_value Value of the limit for Premium users +premiumLimit type:PremiumLimitType default_value:int32 premium_value:int32 = PremiumLimit; + +//@description Contains information about features, available to Premium users @features The list of available features @limits The list of limits, increased for Premium users +premiumFeatures features:vector limits:vector = PremiumFeatures; //@class DeviceToken @description Represents a data needed to subscribe for push notifications through registerDevice method. To use specific push notification service, the correct application platform must be specified and a valid server authentication data must be uploaded at https://my.telegram.org diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 160f9629e..740433c8b 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -1180,7 +1180,56 @@ void ConfigManager::get_premium_features(Promise(std::move(features))); + + const vector limit_keys{"channels_limit", + "saved_gifs_limit", + "stickers_faved_limit", + "dialog_filters_limit", + "dialog_filters_chats_limit", + "dialogs_pinned_limit", + "dialogs_folder_pinned_limit", + "channels_public_limit", + "caption_length_limit"}; + vector> limits; + for (auto key : limit_keys) { + int32 default_limit = static_cast(G()->shared_config().get_option_integer(PSLICE() << key << "_default")); + int32 premium_limit = static_cast(G()->shared_config().get_option_integer(PSLICE() << key << "_premium")); + if (default_limit > 0 && premium_limit > 0) { + auto type = [&]() -> td_api::object_ptr { + if (key == "channels_limit") { + return td_api::make_object(); + } + if (key == "saved_gifs_limit") { + return td_api::make_object(); + } + if (key == "stickers_faved_limit") { + return td_api::make_object(); + } + if (key == "dialog_filters_limit") { + return td_api::make_object(); + } + if (key == "dialog_filters_chats_limit") { + return td_api::make_object(); + } + if (key == "dialogs_pinned_limit") { + return td_api::make_object(); + } + if (key == "dialogs_folder_pinned_limit") { + return td_api::make_object(); + } + if (key == "channels_public_limit") { + return td_api::make_object(); + } + if (key == "caption_length_limit") { + return td_api::make_object(); + } + UNREACHABLE(); + return nullptr; + }(); + limits.push_back(td_api::make_object(std::move(type), default_limit, premium_limit)); + } + } + promise.set_value(td_api::make_object(std::move(features), std::move(limits))); } void ConfigManager::on_result(NetQueryPtr res) { @@ -1522,12 +1571,31 @@ void ConfigManager::process_app_config(tl_object_ptr &c string default_reaction; int64 reactions_uniq_max = 0; vector premium_features; + const vector premium_limit_keys{"channels_limit_default", + "channels_limit_premium", + "saved_gifs_limit_default", + "saved_gifs_limit_premium", + "stickers_faved_limit_default", + "stickers_faved_limit_premium", + "dialog_filters_limit_default", + "dialog_filters_limit_premium", + "dialog_filters_chats_limit_default", + "dialog_filters_chats_limit_premium", + "dialogs_pinned_limit_default", + "dialogs_pinned_limit_premium", + "dialogs_folder_pinned_limit_default", + "dialogs_folder_pinned_limit_premium", + "channels_public_limit_default", + "channels_public_limit_premium", + "caption_length_limit_default", + "caption_length_limit_premium"}; if (config->get_id() == telegram_api::jsonObject::ID) { for (auto &key_value : static_cast(config.get())->value_) { Slice key = key_value->key_; telegram_api::JSONValue *value = key_value->value_.get(); if (key == "test" || key == "wallet_enabled" || key == "wallet_blockchain_name" || key == "wallet_config" || - key == "stickers_emoji_cache_time") { + key == "stickers_emoji_cache_time" || key == "upload_max_fileparts_default" || + key == "upload_max_fileparts_premium") { continue; } if (key == "ignore_restriction_reasons") { @@ -1797,6 +1865,22 @@ void ConfigManager::process_app_config(tl_object_ptr &c } continue; } + bool is_premium_limit_key = false; + for (auto premium_limit_key : premium_limit_keys) { + if (key == premium_limit_key) { + auto setting_value = get_json_value_int(std::move(key_value->value_), key); + if (setting_value > 0) { + G()->shared_config().set_option_integer(key, setting_value); + } else { + LOG(ERROR) << "Receive invalid value " << setting_value << " for " << key; + } + is_premium_limit_key = true; + break; + } + } + if (is_premium_limit_key) { + continue; + } new_values.push_back(std::move(key_value)); } diff --git a/td/telegram/OptionManager.cpp b/td/telegram/OptionManager.cpp index 82826224d..0bdea9e87 100644 --- a/td/telegram/OptionManager.cpp +++ b/td/telegram/OptionManager.cpp @@ -156,11 +156,18 @@ bool OptionManager::is_internal_option(Slice name) { return name == "base_language_pack_version"; case 'c': return name == "call_receive_timeout_ms" || name == "call_ring_timeout_ms" || + name == "caption_length_limit_default" || name == "caption_length_limit_premium" || + name == "channels_limit_default" || name == "channels_limit_premium" || + name == "channels_public_limit_default" || name == "channels_public_limit_premium" || name == "channels_read_media_period" || name == "chat_read_mark_expire_period" || name == "chat_read_mark_size_threshold"; case 'd': - return name == "dc_txt_domain_name" || name == "default_reaction_needs_sync" || name == "dice_emojis" || - name == "dice_success_values"; + return name == "dc_txt_domain_name" || name == "default_reaction_needs_sync" || + name == "dialog_filters_chats_limit_default" || name == "dialog_filters_chats_limit_premium" || + name == "dialog_filters_limit_default" || name == "dialog_filters_limit_premium" || + name == "dialogs_folder_pinned_limit_default" || name == "dialogs_folder_pinned_limit_premium" || + name == "dialogs_pinned_limit_default" || name == "dialogs_pinned_limit_premium" || + name == "dice_emojis" || name == "dice_success_values"; case 'e': return name == "edit_time_limit" || name == "emoji_sounds"; case 'i': @@ -179,7 +186,9 @@ bool OptionManager::is_internal_option(Slice name) { return name == "rating_e_decay" || name == "reactions_uniq_max" || name == "recent_stickers_limit" || name == "revoke_pm_inbox" || name == "revoke_time_limit" || name == "revoke_pm_time_limit"; case 's': - return name == "saved_animations_limit" || name == "session_count"; + return name == "saved_animations_limit" || name == "saved_gifs_limit_default" || + name == "saved_gifs_limit_premium" || name == "session_count" || name == "stickers_faved_limit_default" || + name == "stickers_faved_limit_premium"; case 'v': return name == "video_note_size_max"; case 'w':