From cabd71c3c3e35b892f41d75f89aa89724f6a37e0 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 11 Aug 2023 15:35:13 +0300 Subject: [PATCH] Add weekly and monthly limits for sent stories. --- td/generate/scheme/td_api.tl | 6 ++++++ td/telegram/ConfigManager.cpp | 11 +++++++++-- td/telegram/ConfigManager.h | 2 +- td/telegram/OptionManager.cpp | 4 +++- td/telegram/Premium.cpp | 14 +++++++++++++- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 73d6ec1c4..fddc406dd 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3984,6 +3984,12 @@ premiumLimitTypeShareableChatFolderCount = PremiumLimitType; //@description The maximum number of active stories premiumLimitTypeActiveStoryCount = PremiumLimitType; +//@description The maximum number of stories sent per week +premiumLimitTypeWeeklySentStoryCount = PremiumLimitType; + +//@description The maximum number of stories sent per month +premiumLimitTypeMonthlySentStoryCount = PremiumLimitType; + //@description The maximum length of captions of sent stories premiumLimitTypeStoryCaptionLength = PremiumLimitType; diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index a43bd5bb8..86ed53150 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -2014,6 +2014,10 @@ void ConfigManager::process_app_config(tl_object_ptr &c options.get_option_integer("dialog_filters_chats_limit_premium", 200)); options.set_option_integer("active_story_count_max", options.get_option_integer("story_expiring_limit_premium", 100)); + options.set_option_integer("weekly_sent_story_count_max", + options.get_option_integer("stories_sent_weekly_limit_premium", 700)); + options.set_option_integer("monthly_sent_story_count_max", + options.get_option_integer("stories_sent_monthly_limit_premium", 3000)); options.set_option_integer("story_caption_length_max", options.get_option_integer("story_caption_length_limit_premium", 2048)); options.set_option_integer("bio_length_max", options.get_option_integer("about_length_limit_premium", 140)); @@ -2032,8 +2036,11 @@ void ConfigManager::process_app_config(tl_object_ptr &c options.set_option_integer("chat_folder_count_max", options.get_option_integer("dialog_filters_limit_default", 10)); options.set_option_integer("chat_folder_chosen_chat_count_max", options.get_option_integer("dialog_filters_chats_limit_default", 100)); - options.set_option_integer("active_story_count_max", - options.get_option_integer("story_expiring_limit_default", 30)); + options.set_option_integer("active_story_count_max", options.get_option_integer("story_expiring_limit_default", 3)); + options.set_option_integer("weekly_sent_story_count_max", + options.get_option_integer("stories_sent_weekly_limit_default", 7)); + options.set_option_integer("monthly_sent_story_count_max", + options.get_option_integer("stories_sent_monthly_limit_default", 30)); options.set_option_integer("story_caption_length_max", options.get_option_integer("story_caption_length_limit_default", 200)); options.set_option_integer("bio_length_max", options.get_option_integer("about_length_limit_default", 70)); diff --git a/td/telegram/ConfigManager.h b/td/telegram/ConfigManager.h index 9b245a51f..eea8687e0 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 = 11; + static constexpr int32 CURRENT_VERSION = 12; int32 version_ = 0; int32 hash_ = 0; telegram_api::object_ptr config_; diff --git a/td/telegram/OptionManager.cpp b/td/telegram/OptionManager.cpp index e030bcfbc..4e5906d7c 100644 --- a/td/telegram/OptionManager.cpp +++ b/td/telegram/OptionManager.cpp @@ -311,7 +311,9 @@ bool OptionManager::is_internal_option(Slice name) { name == "saved_gifs_limit_premium" || name == "session_count" || name == "since_last_open" || name == "stickers_faved_limit_default" || name == "stickers_faved_limit_premium" || name == "stickers_normal_by_emoji_per_premium_num" || name == "stickers_premium_by_emoji_num" || - name == "stories_changelog_user_id" || name == "story_caption_length_limit_default" || + name == "stories_changelog_user_id" || name == "stories_sent_monthly_limit_default" || + name == "stories_sent_monthly_limit_premium" || name == "stories_sent_weekly_limit_default" || + name == "stories_sent_weekly_limit_premium" || name == "story_caption_length_limit_default" || name == "story_caption_length_limit_premium" || name == "story_expiring_limit_default" || name == "story_expiring_limit_premium"; case 'v': diff --git a/td/telegram/Premium.cpp b/td/telegram/Premium.cpp index 733e5da06..c8e92c78f 100644 --- a/td/telegram/Premium.cpp +++ b/td/telegram/Premium.cpp @@ -307,7 +307,9 @@ const vector &get_premium_limit_keys() { "chatlist_invites", "chatlists_joined", "story_expiring", - "story_caption_length"}; + "story_caption_length", + "stories_sent_weekly", + "stories_sent_monthly"}; return limit_keys; } @@ -342,6 +344,10 @@ static Slice get_limit_type_key(const td_api::PremiumLimitType *limit_type) { return Slice("story_expiring"); case td_api::premiumLimitTypeStoryCaptionLength::ID: return Slice("story_caption_length"); + case td_api::premiumLimitTypeWeeklySentStoryCount::ID: + return Slice("stories_sent_weekly"); + case td_api::premiumLimitTypeMonthlySentStoryCount::ID: + return Slice("stories_sent_monthly"); default: UNREACHABLE(); return Slice(); @@ -505,6 +511,12 @@ static td_api::object_ptr get_premium_limit_object(Slice k if (key == "story_caption_length") { return td_api::make_object(); } + if (key == "stories_sent_weekly") { + return td_api::make_object(); + } + if (key == "stories_sent_monthly") { + return td_api::make_object(); + } UNREACHABLE(); return nullptr; }();