// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/telegram/Premium.h" #include "td/telegram/ConfigShared.h" #include "td/telegram/Global.h" #include "td/utils/SliceBuilder.h" namespace td { const vector &get_premium_limit_keys() { static 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"}; return limit_keys; } void get_premium_features(Promise> &&promise) { auto premium_features = full_split(G()->shared_config().get_option_string( "premium_features", "double_limits,more_upload,faster_download,voice_to_text,no_ads,unique_reactions,premium_stickers," "advanced_chat_management,profile_badge,animated_userpics"), ','); vector> features; for (const auto &premium_feature : premium_features) { auto feature = [&]() -> td_api::object_ptr { if (premium_feature == "double_limits") { return td_api::make_object(); } if (premium_feature == "more_upload") { return td_api::make_object(); } if (premium_feature == "faster_download") { return td_api::make_object(); } if (premium_feature == "voice_to_text") { return td_api::make_object(); } if (premium_feature == "no_ads") { return td_api::make_object(); } if (premium_feature == "unique_reactions") { return td_api::make_object(); } if (premium_feature == "premium_stickers") { return td_api::make_object(); } if (premium_feature == "advanced_chat_management") { return td_api::make_object(); } if (premium_feature == "profile_badge") { return td_api::make_object(); } if (premium_feature == "animated_userpics") { return td_api::make_object(); } return nullptr; }(); if (feature != nullptr) { features.push_back(std::move(feature)); } } auto &limit_keys = get_premium_limit_keys(); 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))); } } // namespace td