mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Use getters in MTP classes.
This commit is contained in:
@@ -104,10 +104,10 @@ void Changelogs::requestCloudLogs() {
|
||||
resultEmpty = false;
|
||||
break;
|
||||
case mtpc_updatesCombined:
|
||||
resultEmpty = result.c_updatesCombined().vupdates.v.isEmpty();
|
||||
resultEmpty = result.c_updatesCombined().vupdates().v.isEmpty();
|
||||
break;
|
||||
case mtpc_updates:
|
||||
resultEmpty = result.c_updates().vupdates.v.isEmpty();
|
||||
resultEmpty = result.c_updates().vupdates().v.isEmpty();
|
||||
break;
|
||||
case mtpc_updatesTooLong:
|
||||
case mtpc_updateShortSentMessage:
|
||||
|
@@ -179,10 +179,10 @@ bytes::vector ComputeHash(
|
||||
CloudPasswordAlgo ParseCloudPasswordAlgo(const MTPPasswordKdfAlgo &data) {
|
||||
return data.match([](const MTPDpasswordKdfAlgoModPow &data) {
|
||||
return CloudPasswordAlgo(CloudPasswordAlgoModPow{
|
||||
bytes::make_vector(data.vsalt1.v),
|
||||
bytes::make_vector(data.vsalt2.v),
|
||||
data.vg.v,
|
||||
bytes::make_vector(data.vp.v) });
|
||||
bytes::make_vector(data.vsalt1().v),
|
||||
bytes::make_vector(data.vsalt2().v),
|
||||
data.vg().v,
|
||||
bytes::make_vector(data.vp().v) });
|
||||
}, [](const MTPDpasswordKdfAlgoUnknown &data) {
|
||||
return CloudPasswordAlgo();
|
||||
});
|
||||
@@ -190,14 +190,11 @@ CloudPasswordAlgo ParseCloudPasswordAlgo(const MTPPasswordKdfAlgo &data) {
|
||||
|
||||
CloudPasswordCheckRequest ParseCloudPasswordCheckRequest(
|
||||
const MTPDaccount_password &data) {
|
||||
const auto algo = data.vcurrent_algo();
|
||||
return CloudPasswordCheckRequest{
|
||||
(data.has_srp_id() ? data.vsrp_id.v : uint64()),
|
||||
(data.has_srp_B()
|
||||
? bytes::make_vector(data.vsrp_B.v)
|
||||
: bytes::vector()),
|
||||
(data.has_current_algo()
|
||||
? ParseCloudPasswordAlgo(data.vcurrent_algo)
|
||||
: CloudPasswordAlgo())
|
||||
data.vsrp_id().value_or_empty(),
|
||||
bytes::make_vector(data.vsrp_B().value_or_empty()),
|
||||
(algo ? ParseCloudPasswordAlgo(*algo) : CloudPasswordAlgo())
|
||||
};
|
||||
}
|
||||
|
||||
@@ -263,10 +260,10 @@ SecureSecretAlgo ParseSecureSecretAlgo(
|
||||
return data.match([](
|
||||
const MTPDsecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000 &data) {
|
||||
return SecureSecretAlgo(SecureSecretAlgoPBKDF2{
|
||||
bytes::make_vector(data.vsalt.v) });
|
||||
bytes::make_vector(data.vsalt().v) });
|
||||
}, [](const MTPDsecurePasswordKdfAlgoSHA512 &data) {
|
||||
return SecureSecretAlgo(SecureSecretAlgoSHA512{
|
||||
bytes::make_vector(data.vsalt.v) });
|
||||
bytes::make_vector(data.vsalt().v) });
|
||||
}, [](const MTPDsecurePasswordKdfAlgoUnknown &data) {
|
||||
return SecureSecretAlgo();
|
||||
});
|
||||
@@ -307,17 +304,16 @@ CloudPasswordState ParseCloudPasswordState(
|
||||
const MTPDaccount_password &data) {
|
||||
auto result = CloudPasswordState();
|
||||
result.request = ParseCloudPasswordCheckRequest(data);
|
||||
result.unknownAlgorithm = data.has_current_algo() && !result.request;
|
||||
result.unknownAlgorithm = data.vcurrent_algo() && !result.request;
|
||||
result.hasRecovery = data.is_has_recovery();
|
||||
result.notEmptyPassport = data.is_has_secure_values();
|
||||
result.hint = data.has_hint() ? qs(data.vhint) : QString();
|
||||
result.hint = qs(data.vhint().value_or_empty());
|
||||
result.newPassword = ValidateNewCloudPasswordAlgo(
|
||||
ParseCloudPasswordAlgo(data.vnew_algo));
|
||||
ParseCloudPasswordAlgo(data.vnew_algo()));
|
||||
result.newSecureSecret = ValidateNewSecureSecretAlgo(
|
||||
ParseSecureSecretAlgo(data.vnew_secure_algo));
|
||||
result.unconfirmedPattern = data.has_email_unconfirmed_pattern()
|
||||
? qs(data.vemail_unconfirmed_pattern)
|
||||
: QString();
|
||||
ParseSecureSecretAlgo(data.vnew_secure_algo()));
|
||||
result.unconfirmedPattern =
|
||||
qs(data.vemail_unconfirmed_pattern().value_or_empty());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -45,7 +45,7 @@ bool JoinGroupByHash(const Match &match, const QVariant &context) {
|
||||
Auth().api().importChatInvite(hash);
|
||||
}));
|
||||
}, [=](const MTPDchatInviteAlready &data) {
|
||||
if (const auto chat = Auth().data().processChat(data.vchat)) {
|
||||
if (const auto chat = Auth().data().processChat(data.vchat())) {
|
||||
App::wnd()->sessionController()->showPeerHistory(
|
||||
chat,
|
||||
Window::SectionShow::Way::Forward);
|
||||
@@ -260,7 +260,7 @@ bool ResolvePrivatePost(const Match &match, const QVariant &context) {
|
||||
MTP_inputChannel(MTP_int(channelId), MTP_long(0)))
|
||||
)).done([=](const MTPmessages_Chats &result) {
|
||||
result.match([&](const auto &data) {
|
||||
const auto peer = auth->data().processChats(data.vchats);
|
||||
const auto peer = auth->data().processChats(data.vchats());
|
||||
if (peer && peer->id == peerFromChannel(channelId)) {
|
||||
done(peer);
|
||||
} else {
|
||||
@@ -280,10 +280,9 @@ bool HandleUnknown(const Match &match, const QVariant &context) {
|
||||
const auto request = match->captured(1);
|
||||
const auto callback = [=](const MTPDhelp_deepLinkInfo &result) {
|
||||
const auto text = TextWithEntities{
|
||||
qs(result.vmessage),
|
||||
(result.has_entities()
|
||||
? TextUtilities::EntitiesFromMTP(result.ventities.v)
|
||||
: EntitiesInText())
|
||||
qs(result.vmessage()),
|
||||
TextUtilities::EntitiesFromMTP(
|
||||
result.ventities().value_or_empty())
|
||||
};
|
||||
if (result.is_update_app()) {
|
||||
const auto box = std::make_shared<QPointer<BoxContent>>();
|
||||
|
@@ -896,8 +896,8 @@ void MtpChecker::start() {
|
||||
_mtp.send(
|
||||
MTPmessages_GetHistory(
|
||||
MTP_inputPeerChannel(
|
||||
channel.c_inputChannel().vchannel_id,
|
||||
channel.c_inputChannel().vaccess_hash),
|
||||
channel.c_inputChannel().vchannel_id(),
|
||||
channel.c_inputChannel().vaccess_hash()),
|
||||
MTP_int(0), // offset_id
|
||||
MTP_int(0), // offset_date
|
||||
MTP_int(0), // add_offset
|
||||
@@ -936,7 +936,7 @@ auto MtpChecker::parseMessage(const MTPmessages_Messages &result) const
|
||||
LOG(("Update Error: MTP feed message not found."));
|
||||
return std::nullopt;
|
||||
}
|
||||
return parseText(message->c_message().vmessage.v);
|
||||
return parseText(message->c_message().vmessage().v);
|
||||
}
|
||||
|
||||
auto MtpChecker::parseText(const QByteArray &text) const
|
||||
|
Reference in New Issue
Block a user