diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 1af73f74..54a56d40 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2731,8 +2731,8 @@ searchChatMembers chat_id:int53 query:string limit:int32 = ChatMembers; getChatAdministrators chat_id:int53 = Users; -//@description Clears draft messages in all chats -clearAllDraftMessages = Ok; +//@description Clears draft messages in all chats @exclude_secret_chats If true, local draft messages in secret chats will not be cleared +clearAllDraftMessages exclude_secret_chats:Bool = Ok; //@description Returns the notification settings for chats of a given type @scope Types of chats for which to return the notification settings information diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 4c21404b..0fbac693 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 8cc47fd5..08c9c9d0 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -12762,11 +12762,13 @@ void MessagesManager::on_saved_dialog_draft_message(DialogId dialog_id, uint64 g } } -void MessagesManager::clear_all_draft_messages(Promise &&promise) { - for (auto &dialog : dialogs_) { - Dialog *d = dialog.second.get(); - if (d->dialog_id.get_type() == DialogType::SecretChat) { - update_dialog_draft_message(d, nullptr, false, true); +void MessagesManager::clear_all_draft_messages(bool exclude_secret_chats, Promise &&promise) { + if (!exclude_secret_chats) { + for (auto &dialog : dialogs_) { + Dialog *d = dialog.second.get(); + if (d->dialog_id.get_type() == DialogType::SecretChat) { + update_dialog_draft_message(d, nullptr, false, true); + } } } td_->create_handler(std::move(promise))->send(); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 190ffdca..729e1e2f 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1231,7 +1231,7 @@ class MessagesManager : public Actor { Status set_dialog_draft_message(DialogId dialog_id, tl_object_ptr &&draft_message) TD_WARN_UNUSED_RESULT; - void clear_all_draft_messages(Promise &&promise); + void clear_all_draft_messages(bool exclude_secret_chats, Promise &&promise); Status toggle_dialog_is_pinned(DialogId dialog_id, bool is_pinned) TD_WARN_UNUSED_RESULT; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 630ed72f..84c8f258 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5509,7 +5509,7 @@ void Td::on_request(uint64 id, td_api::getChatEventLog &request) { void Td::on_request(uint64 id, const td_api::clearAllDraftMessages &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); - messages_manager_->clear_all_draft_messages(std::move(promise)); + messages_manager_->clear_all_draft_messages(request.exclude_secret_chats_, std::move(promise)); } void Td::on_request(uint64 id, const td_api::downloadFile &request) {