From 59df447fed13851c2f5322eed397c78e70074170 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 20 Jun 2018 21:39:04 +0100 Subject: [PATCH] Request frequent contacts calls category. --- Telegram/SourceFiles/export/data/export_data_types.cpp | 3 +++ Telegram/SourceFiles/export/data/export_data_types.h | 1 + Telegram/SourceFiles/export/export_api_wrap.cpp | 9 ++++++--- .../SourceFiles/export/output/export_output_text.cpp | 7 +++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index 7ca6139014..4bacad3df8 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -947,6 +947,9 @@ bool AppendTopPeers(ContactsList &to, const MTPcontacts_TopPeers &data) { } else if (category == mtpc_topPeerCategoryBotsInline) { append(to.inlineBots, data.vpeers); return true; + } else if (category == mtpc_topPeerCategoryPhoneCalls) { + append(to.phoneCalls, data.vpeers); + return true; } else { return false; } diff --git a/Telegram/SourceFiles/export/data/export_data_types.h b/Telegram/SourceFiles/export/data/export_data_types.h index 92707f46e1..5029d6eb3f 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.h +++ b/Telegram/SourceFiles/export/data/export_data_types.h @@ -216,6 +216,7 @@ struct ContactsList { std::vector list; std::vector correspondents; std::vector inlineBots; + std::vector phoneCalls; }; ContactsList ParseContactsList(const MTPcontacts_Contacts &data); diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index be4dbaca58..5a7984045b 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -632,7 +632,9 @@ void ApiWrap::requestTopPeersSlice() { using Flag = MTPcontacts_GetTopPeers::Flag; mainRequest(MTPcontacts_GetTopPeers( - MTP_flags(Flag::f_correspondents | Flag::f_bots_inline), + MTP_flags(Flag::f_correspondents + | Flag::f_bots_inline + | Flag::f_phone_calls), MTP_int(_contactsProcess->topPeersOffset), MTP_int(kTopPeerSliceLimit), MTP_int(0) // hash @@ -665,9 +667,10 @@ void ApiWrap::requestTopPeersSlice() { auto process = base::take(_contactsProcess); process->done(std::move(process->result)); } else { - _contactsProcess->topPeersOffset = std::max( + _contactsProcess->topPeersOffset = std::max(std::max( _contactsProcess->result.correspondents.size(), - _contactsProcess->result.inlineBots.size()); + _contactsProcess->result.inlineBots.size()), + _contactsProcess->result.phoneCalls.size()); requestTopPeersSlice(); } }).send(); diff --git a/Telegram/SourceFiles/export/output/export_output_text.cpp b/Telegram/SourceFiles/export/output/export_output_text.cpp index c388d31498..98318fe658 100644 --- a/Telegram/SourceFiles/export/output/export_output_text.cpp +++ b/Telegram/SourceFiles/export/output/export_output_text.cpp @@ -552,8 +552,10 @@ Result TextWriter::writeSavedContacts(const Data::ContactsList &data) { } Result TextWriter::writeFrequentContacts(const Data::ContactsList &data) { - const auto size = data.correspondents.size() + data.inlineBots.size(); - if (data.correspondents.empty() && data.inlineBots.empty()) { + const auto size = data.correspondents.size() + + data.inlineBots.size() + + data.phoneCalls.size(); + if (!size) { return Result::Success(); } @@ -602,6 +604,7 @@ Result TextWriter::writeFrequentContacts(const Data::ContactsList &data) { }; writeList(data.correspondents, "Correspondents"); writeList(data.inlineBots, "Inline bots"); + writeList(data.phoneCalls, "Calls"); const auto full = JoinList(kLineBreak, list); if (const auto result = file->writeBlock(full); !result) { return result;