diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 676da242..b9e5543a 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -569,6 +569,7 @@ class ImportContactsQuery : public Td::ResultHandler { vector imported_user_ids_; vector unimported_contact_invites_; int64 random_id_; + size_t sent_size_ = 0; public: explicit ImportContactsQuery(Promise &&promise) : promise_(std::move(promise)) { @@ -595,6 +596,7 @@ class ImportContactsQuery : public Td::ResultHandler { contacts.push_back(input_contacts_[i].get_input_phone_contact(static_cast(i))); } + sent_size_ = size; send_query(G()->net_query_creator().create(telegram_api::contacts_importContacts(std::move(contacts)))); } @@ -632,6 +634,10 @@ class ImportContactsQuery : public Td::ResultHandler { } if (!ptr->retry_contacts_.empty()) { + if (sent_size_ == ptr->retry_contacts_.size()) { + return promise_.set_error(Status::Error(429, "Too Many Requests: retry after 3600")); + } + int64 total_size = static_cast(input_contacts_.size()); vector> contacts; contacts.reserve(ptr->retry_contacts_.size()); @@ -644,6 +650,7 @@ class ImportContactsQuery : public Td::ResultHandler { contacts.push_back(input_contacts_[i].get_input_phone_contact(client_id)); } + sent_size_ = contacts.size(); send_query(G()->net_query_creator().create(telegram_api::contacts_importContacts(std::move(contacts)))); return; }