Save serverHasValidsubcription in the account.

Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
Camila Ayres 2024-10-17 18:40:06 +02:00
parent 664a13189b
commit d0f87c3496
No known key found for this signature in database
GPG key ID: 7A4A6121E88E2AD4
3 changed files with 24 additions and 4 deletions

View file

@ -338,7 +338,7 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s
settings.setValue(QLatin1String(serverVersionC), acc->_serverVersion);
settings.setValue(QLatin1String(serverColorC), acc->_serverColor);
settings.setValue(QLatin1String(serverTextColorC), acc->_serverTextColor);
settings.setValue(QLatin1String(serverHasValidSubscriptionC), acc->capabilities().serverHasValidSubscription());
settings.setValue(QLatin1String(serverHasValidSubscriptionC), acc->serverHasValidSubscription());
if (!acc->_skipE2eeMetadataChecksumValidation) {
settings.remove(QLatin1String(skipE2eeMetadataChecksumValidationC));

View file

@ -1076,13 +1076,28 @@ void Account::setAskUserForMnemonic(const bool ask)
emit askUserForMnemonicChanged();
}
bool Account::serverHasValidSubscription() const
{
return _serverHasValidSubscription;
}
void Account::setServerHasValidSubscription(bool valid)
{
if (_serverHasValidSubscription != valid) {
_serverHasValidSubscription = valid;
}
}
void Account::updateServerSubcription()
{
ConfigFile currentConfig;
if (const auto serverHasValidSubscription = _capabilities.serverHasValidSubscription();
serverHasValidSubscription != currentConfig.serverHasValidSubscription() && !serverHasValidSubscription) {
currentConfig.setServerHasValidSubscription(serverHasValidSubscription);
const auto capabilityValidSubscription = _capabilities.serverHasValidSubscription();
const auto configValidSubscription = currentConfig.serverHasValidSubscription();
if (capabilityValidSubscription != configValidSubscription && !configValidSubscription) {
currentConfig.setServerHasValidSubscription(capabilityValidSubscription);
}
setServerHasValidSubscription(capabilityValidSubscription);
}
void Account::updateDesktopEnterpriseChannel()

View file

@ -409,6 +409,9 @@ public:
[[nodiscard]] unsigned int downloadLimit() const;
void setDownloadLimit(unsigned int kbytes);
[[nodiscard]] bool serverHasValidSubscription() const;
void setServerHasValidSubscription(bool valid);
public slots:
/// Used when forgetting credentials
void clearQNAMCache();
@ -553,6 +556,8 @@ private:
unsigned int _uploadLimit = 0;
unsigned int _downloadLimit = 0;
bool _serverHasValidSubscription = false;
/* IMPORTANT - remove later - FIXME MS@2019-12-07 -->
* TODO: For "Log out" & "Remove account": Remove client CA certs and KEY!
*