Skip to content

Commit

Permalink
Request frequent contacts calls category.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 20, 2018
1 parent a253d34 commit 59df447
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/export/data/export_data_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/export/data/export_data_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ struct ContactsList {
std::vector<ContactInfo> list;
std::vector<TopPeer> correspondents;
std::vector<TopPeer> inlineBots;
std::vector<TopPeer> phoneCalls;
};

ContactsList ParseContactsList(const MTPcontacts_Contacts &data);
Expand Down
9 changes: 6 additions & 3 deletions Telegram/SourceFiles/export/export_api_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 5 additions & 2 deletions Telegram/SourceFiles/export/output/export_output_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 59df447

Please sign in to comment.