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_account.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();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
int PremiumLimits::appConfigLimit(
|
|
|
|
const QString &key,
|
2022-08-02 09:40:55 +00:00
|
|
|
int fallback) const {
|
|
|
|
return _session->account().appConfig().get<int>(key, fallback);
|
2022-06-15 22:24:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PremiumLimits::isPremium() const {
|
|
|
|
return _session->premium();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Data
|