diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a01dbfcd7..c595f9eec 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -7831,6 +7831,9 @@ setAutoDownloadSettings settings:autoDownloadSettings type:NetworkType = Ok; //@description Returns autosave settings for the current user getAutosaveSettings = AutosaveSettings; +//@description Clears the list of all autosave settings exceptions +clearAutosaveSettingsExceptions = Ok; + //@description Returns information about a bank card @bank_card_number The bank card number getBankCardInfo bank_card_number:string = BankCardInfo; diff --git a/td/telegram/AutosaveManager.cpp b/td/telegram/AutosaveManager.cpp index cabd3c5ab..62e22ac89 100644 --- a/td/telegram/AutosaveManager.cpp +++ b/td/telegram/AutosaveManager.cpp @@ -24,7 +24,7 @@ class GetAutosaveSettingsQuery final : public Td::ResultHandler { } void send() { - send_query(G()->net_query_creator().create(telegram_api::account_getAutoSaveSettings())); + send_query(G()->net_query_creator().create(telegram_api::account_getAutoSaveSettings(), {{"me"}})); } void on_result(BufferSlice packet) final { @@ -43,6 +43,32 @@ class GetAutosaveSettingsQuery final : public Td::ResultHandler { } }; +class DeleteAutosaveExceptionsQuery final : public Td::ResultHandler { + Promise promise_; + + public: + explicit DeleteAutosaveExceptionsQuery(Promise &&promise) : promise_(std::move(promise)) { + } + + void send() { + send_query(G()->net_query_creator().create(telegram_api::account_deleteAutoSaveExceptions(), {{"me"}})); + } + + 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)); + td_->autosave_manager_->reload_autosave_settings(Auto()); + } +}; + AutosaveManager::AutosaveManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) { } @@ -82,6 +108,10 @@ void AutosaveManager::get_autosave_settings(Promise> &&promise) { load_settings_queries_.push_back(std::move(promise)); if (load_settings_queries_.size() != 1) { return; @@ -127,4 +157,9 @@ void AutosaveManager::on_get_autosave_settings( } } +void AutosaveManager::clear_autosave_settings_excpetions(Promise &&promise) { + settings_.exceptions_.clear(); + td_->create_handler(std::move(promise))->send(); +} + } // namespace td diff --git a/td/telegram/AutosaveManager.h b/td/telegram/AutosaveManager.h index 9da888ea1..1910851a6 100644 --- a/td/telegram/AutosaveManager.h +++ b/td/telegram/AutosaveManager.h @@ -25,8 +25,12 @@ class AutosaveManager final : public Actor { public: AutosaveManager(Td *td, ActorShared<> parent); + void reload_autosave_settings(Promise> &&promise); + void get_autosave_settings(Promise> &&promise); + void clear_autosave_settings_excpetions(Promise &&promise); + private: struct DialogAutosaveSettings { bool autosave_photos_ = false; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 46419e82d..d4d4c03b7 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -4952,6 +4952,12 @@ void Td::on_request(uint64 id, const td_api::getAutosaveSettings &request) { autosave_manager_->get_autosave_settings(std::move(promise)); } +void Td::on_request(uint64 id, const td_api::clearAutosaveSettingsExceptions &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + autosave_manager_->clear_autosave_settings_excpetions(std::move(promise)); +} + void Td::on_request(uint64 id, const td_api::getTopChats &request) { CHECK_IS_USER(); CREATE_REQUEST_PROMISE(); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index f6e5190eb..27eb84d97 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -592,6 +592,8 @@ class Td final : public Actor { void on_request(uint64 id, const td_api::getAutosaveSettings &request); + void on_request(uint64 id, const td_api::clearAutosaveSettingsExceptions &request); + void on_request(uint64 id, const td_api::getTopChats &request); void on_request(uint64 id, const td_api::removeTopChat &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index be72415c3..827034313 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2833,6 +2833,8 @@ class CliClient final : public Actor { td_api::make_object(), as_network_type(args))); } else if (op == "gaus") { send_request(td_api::make_object()); + } else if (op == "cause") { + send_request(td_api::make_object()); } else if (op == "ansc") { int32 sent_bytes; int32 received_bytes;