From 7c6ede090882549ef65fd3732039a9ae63f85743 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 15 Jul 2019 10:30:38 +0200 Subject: [PATCH] Save domain in different localstorage key. --- Telegram/SourceFiles/facades.cpp | 4 ++-- Telegram/SourceFiles/mtproto/config_loader.cpp | 4 ++-- .../SourceFiles/mtproto/special_config_request.cpp | 12 ++++++++---- Telegram/SourceFiles/storage/localstorage.cpp | 9 ++++++++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 79019b3e5..2a417e3ef 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -384,8 +384,8 @@ struct Data { int32 CallPacketTimeoutMs = 10000; int32 WebFileDcId = cTestMode() ? 2 : 4; QString TxtDomainString = cTestMode() - ? qsl("testapv2.stel.com") - : qsl("apv2.stel.com"); + ? qsl("tapv3.stel.com") + : qsl("apv3.stel.com"); bool PhoneCallsEnabled = true; bool BlockedMode = false; int32 CaptionLengthMax = 1024; diff --git a/Telegram/SourceFiles/mtproto/config_loader.cpp b/Telegram/SourceFiles/mtproto/config_loader.cpp index 890c15b00..7c9fa99b5 100644 --- a/Telegram/SourceFiles/mtproto/config_loader.cpp +++ b/Telegram/SourceFiles/mtproto/config_loader.cpp @@ -137,7 +137,7 @@ void ConfigLoader::addSpecialEndpoint( const std::string &ip, int port, bytes::const_span secret) { - auto endpoint = SpecialEndpoint { + const auto endpoint = SpecialEndpoint { dcId, ip, port, @@ -198,7 +198,7 @@ void ConfigLoader::sendSpecialRequest() { void ConfigLoader::specialConfigLoaded(const MTPConfig &result) { Expects(result.type() == mtpc_config); - auto &data = result.c_config(); + const auto &data = result.c_config(); if (data.vdc_options().v.empty()) { LOG(("MTP Error: config with empty dc_options received!")); return; diff --git a/Telegram/SourceFiles/mtproto/special_config_request.cpp b/Telegram/SourceFiles/mtproto/special_config_request.cpp index 45820de68..4e011843a 100644 --- a/Telegram/SourceFiles/mtproto/special_config_request.cpp +++ b/Telegram/SourceFiles/mtproto/special_config_request.cpp @@ -477,18 +477,22 @@ void SpecialConfigRequest::handleResponse(const QByteArray &bytes) { } Assert(_simpleConfig.type() == mtpc_help_configSimple); const auto &config = _simpleConfig.c_help_configSimple(); - const auto now = base::unixtime::now(); + const auto now = base::unixtime::http_now(); if (now > config.vexpires().v) { - LOG(("Config Error: Bad date frame for simple config: %1-%2, our time is %3.").arg(config.vdate().v).arg(config.vexpires().v).arg(now)); + LOG(("Config Error: " + "Bad date frame for simple config: %1-%2, our time is %3." + ).arg(config.vdate().v + ).arg(config.vexpires().v + ).arg(now)); return; } if (config.vrules().v.empty()) { LOG(("Config Error: Empty simple config received.")); return; } - for (auto &rule : config.vrules().v) { + for (const auto &rule : config.vrules().v) { Assert(rule.type() == mtpc_accessPointRule); - auto &data = rule.c_accessPointRule(); + const auto &data = rule.c_accessPointRule(); const auto phoneRules = qs(data.vphone_prefix_rules()); if (!CheckPhoneByPrefixesRules(_phone, phoneRules)) { continue; diff --git a/Telegram/SourceFiles/storage/localstorage.cpp b/Telegram/SourceFiles/storage/localstorage.cpp index 69d7fda34..9699d5d75 100644 --- a/Telegram/SourceFiles/storage/localstorage.cpp +++ b/Telegram/SourceFiles/storage/localstorage.cpp @@ -603,7 +603,7 @@ enum { dbiStickersFavedLimit = 0x50, dbiSuggestStickersByEmoji = 0x51, dbiSuggestEmoji = 0x52, - dbiTxtDomainString = 0x53, + dbiTxtDomainStringOld = 0x53, dbiThemeKey = 0x54, dbiTileBackground = 0x55, dbiCacheSettingsOld = 0x56, @@ -613,6 +613,7 @@ enum { dbiLanguagesKey = 0x5a, dbiCallSettings = 0x5b, dbiCacheSettings = 0x5c, + dbiTxtDomainString = 0x5d, dbiEncryptedWithSalt = 333, dbiEncrypted = 444, @@ -1226,6 +1227,12 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting Global::RefWorkMode().set(newMode()); } break; + case dbiTxtDomainStringOld: { + QString v; + stream >> v; + if (!_checkStreamStatus(stream)) return false; + } break; + case dbiTxtDomainString: { QString v; stream >> v;