diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 43b0ab55e..86b6151bc 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -8431,6 +8431,9 @@ stopPoll chat_id:int53 message_id:int53 reply_markup:ReplyMarkup = Ok; //@description Hides a suggested action @action Suggested action to hide hideSuggestedAction action:SuggestedAction = Ok; +//@description Hides the list of contacts that have close birthdays for 24 hours +hideContactCloseBirthdays = Ok; + //@description Returns information about a business connection by its identifier; for bots only @connection_id Identifier of the business connection to return getBusinessConnection connection_id:string = BusinessConnection; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index e179e791b..7a251ebc1 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -8892,6 +8892,13 @@ void Td::on_request(uint64 id, const td_api::hideSuggestedAction &request) { dismiss_suggested_action(SuggestedAction(request.action_), std::move(promise)); } +void Td::on_request(uint64 id, const td_api::hideContactCloseBirthdays &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + option_manager_->set_option_boolean("dismiss_birthday_contact_today", true); + user_manager_->hide_contact_birthdays(std::move(promise)); +} + void Td::on_request(uint64 id, td_api::getBusinessConnection &request) { CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.connection_id_); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 777021c97..6bbb3f2a6 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1693,6 +1693,8 @@ class Td final : public Actor { void on_request(uint64 id, const td_api::hideSuggestedAction &request); + void on_request(uint64 id, const td_api::hideContactCloseBirthdays &request); + void on_request(uint64 id, td_api::getBusinessConnection &request); void on_request(uint64 id, const td_api::getLoginUrlInfo &request); diff --git a/td/telegram/UserManager.cpp b/td/telegram/UserManager.cpp index b31320069..dee6aaf7c 100644 --- a/td/telegram/UserManager.cpp +++ b/td/telegram/UserManager.cpp @@ -137,6 +137,32 @@ class GetContactsBirthdaysQuery final : public Td::ResultHandler { } }; +class DismissContactBirtdaysSuggestionQuery final : public Td::ResultHandler { + Promise promise_; + + public: + explicit DismissContactBirtdaysSuggestionQuery(Promise &&promise) : promise_(std::move(promise)) { + } + + void send() { + send_query(G()->net_query_creator().create(telegram_api::help_dismissSuggestion( + telegram_api::make_object(), "BIRTHDAY_CONTACTS_TODAY"))); + } + + void on_result(BufferSlice packet) final { + auto result_ptr = fetch_result(packet); + if (result_ptr.is_error()) { + return on_error(result_ptr.move_as_error()); + } + + promise_.set_value(Unit()); + } + + void on_error(Status status) final { + promise_.set_error(std::move(status)); + } +}; + class GetContactsStatusesQuery final : public Td::ResultHandler { public: void send() { @@ -6546,6 +6572,10 @@ void UserManager::on_get_contact_birthdates( // there is no need to save them between restarts } +void UserManager::hide_contact_birthdays(Promise &&promise) { + td_->create_handler(std::move(promise))->send(); +} + vector UserManager::get_close_friends(Promise &&promise) { if (!are_contacts_loaded_) { load_contacts(std::move(promise)); diff --git a/td/telegram/UserManager.h b/td/telegram/UserManager.h index 82936bc15..36785ce90 100644 --- a/td/telegram/UserManager.h +++ b/td/telegram/UserManager.h @@ -421,6 +421,8 @@ class UserManager final : public Actor { void on_get_contact_birthdates(telegram_api::object_ptr &&birthdays); + void hide_contact_birthdays(Promise &&promise); + vector get_close_friends(Promise &&promise); void set_close_friends(vector user_ids, Promise &&promise); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index f1dbe0515..928d91a5c 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -6650,6 +6650,8 @@ class CliClient final : public Actor { send_request(td_api::make_object(chat_id, token, x)); } else if (op == "hsa") { send_request(td_api::make_object(as_suggested_action(args))); + } else if (op == "hccb") { + send_request(td_api::make_object()); } else if (op == "glui" || op == "glu" || op == "glua") { ChatId chat_id; MessageId message_id;