diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 9a1efe5b6..e1f9ff61c 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -9143,6 +9143,9 @@ searchBackground name:string = Background; //@for_dark_theme Pass true if the background is set for a dark theme setDefaultBackground background:InputBackground type:BackgroundType for_dark_theme:Bool = Background; +//@description Deletes default background for chats @for_dark_theme Pass true if the background is deleted for a dark theme +deleteDefaultBackground for_dark_theme:Bool = Ok; + //@description Returns backgrounds installed by the user @for_dark_theme Pass true to order returned backgrounds for a dark theme getInstalledBackgrounds for_dark_theme:Bool = Backgrounds; diff --git a/td/telegram/BackgroundManager.cpp b/td/telegram/BackgroundManager.cpp index 5e7fec583..090f8741c 100644 --- a/td/telegram/BackgroundManager.cpp +++ b/td/telegram/BackgroundManager.cpp @@ -683,11 +683,7 @@ void BackgroundManager::set_background(const td_api::InputBackground *input_back TRY_RESULT_PROMISE(promise, type, BackgroundType::get_background_type(background_type, 0)); if (input_background == nullptr) { - if (background_type == nullptr) { - set_background_id(BackgroundId(), BackgroundType(), for_dark_theme); - return promise.set_value(nullptr); - } - if (type.has_file()) { + if (background_type == nullptr || type.has_file()) { return promise.set_error(Status::Error(400, "Input background must be non-empty for the background type")); } @@ -732,6 +728,11 @@ void BackgroundManager::set_background(const td_api::InputBackground *input_back } } +void BackgroundManager::delete_background(bool for_dark_theme, Promise &&promise) { + set_background_id(BackgroundId(), BackgroundType(), for_dark_theme); + promise.set_value(Unit()); +} + Result BackgroundManager::get_background_dialog(DialogId dialog_id) { if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_dialog_background")) { return Status::Error(400, "Chat not found"); diff --git a/td/telegram/BackgroundManager.h b/td/telegram/BackgroundManager.h index 26173e467..490b95ee1 100644 --- a/td/telegram/BackgroundManager.h +++ b/td/telegram/BackgroundManager.h @@ -44,6 +44,8 @@ class BackgroundManager final : public Actor { void set_background(const td_api::InputBackground *input_background, const td_api::BackgroundType *background_type, bool for_dark_theme, Promise> &&promise); + void delete_background(bool for_dark_theme, Promise &&promise); + void remove_background(BackgroundId background_id, Promise &&promise); void reset_backgrounds(Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index ea7303ce3..2e161ed0b 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -8790,6 +8790,12 @@ void Td::on_request(uint64 id, td_api::setDefaultBackground &request) { std::move(promise)); } +void Td::on_request(uint64 id, const td_api::deleteDefaultBackground &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + background_manager_->delete_background(request.for_dark_theme_, std::move(promise)); +} + void Td::on_request(uint64 id, const td_api::removeInstalledBackground &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index f015e14ed..75c22113f 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1599,6 +1599,8 @@ class Td final : public Actor { void on_request(uint64 id, td_api::setDefaultBackground &request); + void on_request(uint64 id, const td_api::deleteDefaultBackground &request); + void on_request(uint64 id, const td_api::removeInstalledBackground &request); void on_request(uint64 id, const td_api::resetInstalledBackgrounds &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 38c17baab..7e7c0b7cc 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3128,6 +3128,8 @@ class CliClient final : public Actor { BackgroundType background_type; get_args(args, input_background, background_type); send_request(td_api::make_object(input_background, background_type, op == "sdbd")); + } else if (op == "ddb" || op == "ddbd") { + send_request(td_api::make_object(op == "ddbd")); } else if (op == "rib") { int64 background_id; get_args(args, background_id);