mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-15 19:47:03 +00:00
Submit local Peer2PeerNobody setting to the cloud.
This commit is contained in:
parent
8d27d8efcf
commit
e737fa59b3
@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
namespace {
|
||||
|
||||
constexpr auto kAutoLockTimeoutLateMs = TimeMs(3000);
|
||||
constexpr auto kLegacyCallsPeerToPeerNobody = 4;
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -78,7 +79,7 @@ QByteArray AuthSessionSettings::serialize() const {
|
||||
stream << qint32(_variables.thirdColumnWidth.current());
|
||||
stream << qint32(_variables.thirdSectionExtendedBy);
|
||||
stream << qint32(_variables.sendFilesWay);
|
||||
stream << qint32(_variables.callsPeerToPeer.current());
|
||||
stream << qint32(0);// LEGACY _variables.callsPeerToPeer.current());
|
||||
stream << qint32(_variables.sendSubmitWay);
|
||||
stream << qint32(_variables.supportSwitch);
|
||||
stream << qint32(_variables.supportFixChatsOrder ? 1 : 0);
|
||||
@ -109,7 +110,7 @@ void AuthSessionSettings::constructFromSerialized(const QByteArray &serialized)
|
||||
int thirdColumnWidth = _variables.thirdColumnWidth.current();
|
||||
int thirdSectionExtendedBy = _variables.thirdSectionExtendedBy;
|
||||
qint32 sendFilesWay = static_cast<qint32>(_variables.sendFilesWay);
|
||||
qint32 callsPeerToPeer = qint32(_variables.callsPeerToPeer.current());
|
||||
qint32 legacyCallsPeerToPeer = qint32(0);
|
||||
qint32 sendSubmitWay = static_cast<qint32>(_variables.sendSubmitWay);
|
||||
qint32 supportSwitch = static_cast<qint32>(_variables.supportSwitch);
|
||||
qint32 supportFixChatsOrder = _variables.supportFixChatsOrder ? 1 : 0;
|
||||
@ -168,7 +169,7 @@ void AuthSessionSettings::constructFromSerialized(const QByteArray &serialized)
|
||||
stream >> sendFilesWay;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> callsPeerToPeer;
|
||||
stream >> legacyCallsPeerToPeer;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> sendSubmitWay;
|
||||
@ -225,14 +226,6 @@ void AuthSessionSettings::constructFromSerialized(const QByteArray &serialized)
|
||||
case SendFilesWay::Photos:
|
||||
case SendFilesWay::Files: _variables.sendFilesWay = uncheckedSendFilesWay; break;
|
||||
}
|
||||
auto uncheckedCallsPeerToPeer = static_cast<Calls::PeerToPeer>(callsPeerToPeer);
|
||||
switch (uncheckedCallsPeerToPeer) {
|
||||
case Calls::PeerToPeer::DefaultContacts:
|
||||
case Calls::PeerToPeer::DefaultEveryone:
|
||||
case Calls::PeerToPeer::Everyone:
|
||||
case Calls::PeerToPeer::Contacts:
|
||||
case Calls::PeerToPeer::Nobody: _variables.callsPeerToPeer = uncheckedCallsPeerToPeer; break;
|
||||
}
|
||||
auto uncheckedSendSubmitWay = static_cast<Ui::InputSubmitSettings>(
|
||||
sendSubmitWay);
|
||||
switch (uncheckedSendSubmitWay) {
|
||||
@ -249,6 +242,7 @@ void AuthSessionSettings::constructFromSerialized(const QByteArray &serialized)
|
||||
_variables.supportFixChatsOrder = (supportFixChatsOrder == 1);
|
||||
_variables.supportTemplatesAutocomplete = (supportTemplatesAutocomplete == 1);
|
||||
_variables.supportChatsTimeSlice = supportChatsTimeSlice;
|
||||
_variables.hadLegacyCallsPeerToPeerNobody = (legacyCallsPeerToPeer == kLegacyCallsPeerToPeerNobody);
|
||||
}
|
||||
|
||||
void AuthSessionSettings::setSupportChatsTimeSlice(int slice) {
|
||||
@ -416,6 +410,18 @@ bool AuthSession::validateSelf(const MTPUser &user) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void AuthSession::moveSettingsFrom(AuthSessionSettings &&other) {
|
||||
_settings.moveFrom(std::move(other));
|
||||
if (_settings.hadLegacyCallsPeerToPeerNobody()) {
|
||||
api().savePrivacy(
|
||||
MTP_inputPrivacyKeyPhoneP2P(),
|
||||
QVector<MTPInputPrivacyRule>(
|
||||
1,
|
||||
MTP_inputPrivacyValueDisallowAll()));
|
||||
saveSettingsDelayed();
|
||||
}
|
||||
}
|
||||
|
||||
void AuthSession::saveSettingsDelayed(TimeMs delay) {
|
||||
Expects(this == &Auth());
|
||||
|
||||
|
@ -28,10 +28,6 @@ namespace Data {
|
||||
class Session;
|
||||
} // namespace Data
|
||||
|
||||
namespace Calls {
|
||||
enum class PeerToPeer;
|
||||
} // namespace Calls
|
||||
|
||||
namespace Storage {
|
||||
class Downloader;
|
||||
class Uploader;
|
||||
@ -186,14 +182,8 @@ public:
|
||||
_variables.groupStickersSectionHidden.remove(peerId);
|
||||
}
|
||||
|
||||
rpl::producer<Calls::PeerToPeer> callsPeerToPeerValue() const {
|
||||
return _variables.callsPeerToPeer.value();
|
||||
}
|
||||
Calls::PeerToPeer callsPeerToPeer() const {
|
||||
return _variables.callsPeerToPeer.current();
|
||||
}
|
||||
void setCallsPeerToPeer(Calls::PeerToPeer value) {
|
||||
_variables.callsPeerToPeer = value;
|
||||
bool hadLegacyCallsPeerToPeerNobody() const {
|
||||
return _variables.hadLegacyCallsPeerToPeerNobody;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -219,9 +209,8 @@ private:
|
||||
= kDefaultDialogsWidthRatio; // per-window
|
||||
rpl::variable<int> thirdColumnWidth
|
||||
= kDefaultThirdColumnWidth; // per-window
|
||||
rpl::variable<Calls::PeerToPeer> callsPeerToPeer
|
||||
= Calls::PeerToPeer();
|
||||
Ui::InputSubmitSettings sendSubmitWay;
|
||||
bool hadLegacyCallsPeerToPeerNobody = false;
|
||||
|
||||
static constexpr auto kDefaultSupportChatsLimitSlice
|
||||
= 30 * 24 * 60 * 60;
|
||||
@ -290,6 +279,7 @@ public:
|
||||
AuthSessionSettings &settings() {
|
||||
return _settings;
|
||||
}
|
||||
void moveSettingsFrom(AuthSessionSettings &&other);
|
||||
void saveSettingsDelayed(TimeMs delay = kDefaultSaveDelay);
|
||||
|
||||
ApiWrap &api() {
|
||||
|
@ -18,14 +18,6 @@ class Track;
|
||||
|
||||
namespace Calls {
|
||||
|
||||
enum class PeerToPeer {
|
||||
DefaultContacts,
|
||||
DefaultEveryone,
|
||||
Everyone,
|
||||
Contacts,
|
||||
Nobody,
|
||||
};
|
||||
|
||||
class Panel;
|
||||
|
||||
class Instance : private MTP::Sender, private Call::Delegate, private base::Subscriber, public base::has_weak_ptr {
|
||||
|
@ -499,7 +499,7 @@ void Messenger::startMtp() {
|
||||
}
|
||||
if (_private->storedAuthSession) {
|
||||
if (_authSession) {
|
||||
_authSession->settings().moveFrom(
|
||||
_authSession->moveSettingsFrom(
|
||||
std::move(*_private->storedAuthSession));
|
||||
}
|
||||
_private->storedAuthSession.reset();
|
||||
|
Loading…
Reference in New Issue
Block a user