2022-06-15 22:24:10 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#include "data/data_premium_limits.h"
|
|
|
|
|
|
|
|
#include "main/main_app_config.h"
|
|
|
|
#include "main/main_session.h"
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
PremiumLimits::PremiumLimits(not_null<Main::Session*> session)
|
|
|
|
: _session(session) {
|
|
|
|
}
|
|
|
|
|
|
|
|
int PremiumLimits::channelsDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("channels_limit_default", 500);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::channelsPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("channels_limit_premium", 1000);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::channelsCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? channelsPremium()
|
|
|
|
: channelsDefault();
|
|
|
|
}
|
|
|
|
|
2023-11-28 08:54:17 +00:00
|
|
|
int PremiumLimits::similarChannelsDefault() const {
|
|
|
|
return appConfigLimit("recommended_channels_limit_default", 10);
|
|
|
|
}
|
|
|
|
int PremiumLimits::similarChannelsPremium() const {
|
|
|
|
return appConfigLimit("recommended_channels_limit_premium", 100);
|
|
|
|
}
|
|
|
|
int PremiumLimits::similarChannelsCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? channelsPremium()
|
|
|
|
: channelsDefault();
|
|
|
|
}
|
|
|
|
|
2022-06-15 22:24:10 +00:00
|
|
|
int PremiumLimits::gifsDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("saved_gifs_limit_default", 200);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::gifsPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("saved_gifs_limit_premium", 400);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::gifsCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? gifsPremium()
|
|
|
|
: gifsDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
int PremiumLimits::stickersFavedDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("stickers_faved_limit_default", 5);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::stickersFavedPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("stickers_faved_limit_premium", 10);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::stickersFavedCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? stickersFavedPremium()
|
|
|
|
: stickersFavedDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
int PremiumLimits::dialogFiltersDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("dialog_filters_limit_default", 10);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::dialogFiltersPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("dialog_filters_limit_premium", 20);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::dialogFiltersCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? dialogFiltersPremium()
|
|
|
|
: dialogFiltersDefault();
|
|
|
|
}
|
|
|
|
|
2023-04-03 13:42:01 +00:00
|
|
|
int PremiumLimits::dialogShareableFiltersDefault() const {
|
|
|
|
return appConfigLimit("chatlists_joined_limit_default", 2);
|
|
|
|
}
|
|
|
|
int PremiumLimits::dialogShareableFiltersPremium() const {
|
|
|
|
return appConfigLimit("chatlists_joined_limit_premium", 20);
|
|
|
|
}
|
|
|
|
int PremiumLimits::dialogShareableFiltersCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? dialogShareableFiltersPremium()
|
|
|
|
: dialogShareableFiltersDefault();
|
|
|
|
}
|
|
|
|
|
2022-06-15 22:24:10 +00:00
|
|
|
int PremiumLimits::dialogFiltersChatsDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("dialog_filters_chats_limit_default", 100);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::dialogFiltersChatsPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("dialog_filters_chats_limit_premium", 200);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::dialogFiltersChatsCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? dialogFiltersChatsPremium()
|
|
|
|
: dialogFiltersChatsDefault();
|
|
|
|
}
|
|
|
|
|
2023-04-03 13:42:01 +00:00
|
|
|
int PremiumLimits::dialogFiltersLinksDefault() const {
|
|
|
|
return appConfigLimit("chatlist_invites_limit_default", 3);
|
|
|
|
}
|
|
|
|
int PremiumLimits::dialogFiltersLinksPremium() const {
|
|
|
|
return appConfigLimit("chatlist_invites_limit_premium", 20);
|
|
|
|
}
|
|
|
|
int PremiumLimits::dialogFiltersLinksCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? dialogFiltersLinksPremium()
|
|
|
|
: dialogFiltersLinksDefault();
|
|
|
|
}
|
|
|
|
|
2022-06-15 22:24:10 +00:00
|
|
|
int PremiumLimits::dialogsPinnedDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("dialogs_pinned_limit_default", 5);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::dialogsPinnedPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("dialogs_pinned_limit_premium", 10);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::dialogsPinnedCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? dialogsPinnedPremium()
|
|
|
|
: dialogsPinnedDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
int PremiumLimits::dialogsFolderPinnedDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("dialogs_folder_pinned_limit_default", 100);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::dialogsFolderPinnedPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("dialogs_folder_pinned_limit_premium", 200);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::dialogsFolderPinnedCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? dialogsFolderPinnedPremium()
|
|
|
|
: dialogsFolderPinnedDefault();
|
|
|
|
}
|
|
|
|
|
2022-12-01 17:44:32 +00:00
|
|
|
int PremiumLimits::topicsPinnedCurrent() const {
|
|
|
|
return appConfigLimit("topics_pinned_limit", 5);
|
|
|
|
}
|
|
|
|
|
2023-12-27 01:09:20 +00:00
|
|
|
int PremiumLimits::savedSublistsPinnedDefault() const {
|
|
|
|
return appConfigLimit("saved_dialogs_pinned_limit_default", 5);
|
|
|
|
}
|
|
|
|
int PremiumLimits::savedSublistsPinnedPremium() const {
|
|
|
|
return appConfigLimit("saved_dialogs_pinned_limit_premium", 100);
|
|
|
|
}
|
|
|
|
int PremiumLimits::savedSublistsPinnedCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? savedSublistsPinnedPremium()
|
|
|
|
: savedSublistsPinnedDefault();
|
|
|
|
}
|
|
|
|
|
2022-06-15 22:24:10 +00:00
|
|
|
int PremiumLimits::channelsPublicDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("channels_public_limit_default", 10);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::channelsPublicPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("channels_public_limit_premium", 20);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::channelsPublicCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? channelsPublicPremium()
|
|
|
|
: channelsPublicDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
int PremiumLimits::captionLengthDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("caption_length_limit_default", 1024);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::captionLengthPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("caption_length_limit_premium", 2048);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::captionLengthCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? captionLengthPremium()
|
|
|
|
: captionLengthDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
int PremiumLimits::uploadMaxDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("upload_max_fileparts_default", 4000);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::uploadMaxPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("upload_max_fileparts_premium", 8000);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::uploadMaxCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? uploadMaxPremium()
|
|
|
|
: uploadMaxDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
int PremiumLimits::aboutLengthDefault() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("about_length_limit_default", 70);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::aboutLengthPremium() const {
|
2022-08-02 09:40:55 +00:00
|
|
|
return appConfigLimit("about_length_limit_premium", 140);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
int PremiumLimits::aboutLengthCurrent() const {
|
|
|
|
return isPremium()
|
|
|
|
? aboutLengthPremium()
|
|
|
|
: aboutLengthDefault();
|
|
|
|
}
|
|
|
|
|
2023-11-29 14:25:27 +00:00
|
|
|
int PremiumLimits::maxBoostLevel() const {
|
|
|
|
return appConfigLimit(
|
|
|
|
u"boosts_channel_level_max"_q,
|
|
|
|
_session->isTestMode() ? 9 : 99);
|
|
|
|
}
|
|
|
|
|
2022-06-15 22:24:10 +00:00
|
|
|
int PremiumLimits::appConfigLimit(
|
|
|
|
const QString &key,
|
2022-08-02 09:40:55 +00:00
|
|
|
int fallback) const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(key, fallback);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PremiumLimits::isPremium() const {
|
|
|
|
return _session->premium();
|
|
|
|
}
|
|
|
|
|
2024-03-06 23:27:15 +00:00
|
|
|
LevelLimits::LevelLimits(not_null<Main::Session*> session)
|
|
|
|
: _session(session) {
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::channelColorLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"channel_color_level_min"_q,
|
|
|
|
5);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::channelBgIconLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"channel_bg_icon_level_min"_q,
|
|
|
|
4);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::channelProfileBgIconLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"channel_profile_bg_icon_level_min"_q,
|
|
|
|
7);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::channelEmojiStatusLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"channel_emoji_status_level_min"_q,
|
|
|
|
8);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::channelWallpaperLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"channel_wallpaper_level_min"_q,
|
|
|
|
9);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::channelCustomWallpaperLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"channel_custom_wallpaper_level_min"_q,
|
|
|
|
10);
|
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:55 +00:00
|
|
|
int LevelLimits::channelRestrictSponsoredLevelMin() const {
|
|
|
|
return _session->appConfig().get<int>(
|
|
|
|
u"channel_restrict_sponsored_level_min"_q,
|
|
|
|
20);
|
|
|
|
}
|
|
|
|
|
2024-03-06 23:27:15 +00:00
|
|
|
int LevelLimits::groupTranscribeLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"group_transcribe_level_min"_q,
|
|
|
|
6);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::groupEmojiStickersLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"group_emoji_stickers_level_min"_q,
|
|
|
|
4);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::groupProfileBgIconLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"group_profile_bg_icon_level_min"_q,
|
|
|
|
5);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::groupEmojiStatusLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"group_emoji_status_level_min"_q,
|
|
|
|
8);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::groupWallpaperLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"group_wallpaper_level_min"_q,
|
|
|
|
9);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LevelLimits::groupCustomWallpaperLevelMin() const {
|
2024-03-29 11:30:50 +00:00
|
|
|
return _session->appConfig().get<int>(
|
2024-03-06 23:27:15 +00:00
|
|
|
u"group_custom_wallpaper_level_min"_q,
|
|
|
|
10);
|
|
|
|
}
|
|
|
|
|
2022-06-15 22:24:10 +00:00
|
|
|
} // namespace Data
|