From fc966adca9b4f5f7dac5302a8ec926d652c0d4aa Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 19 Jul 2018 17:23:18 +0300 Subject: [PATCH] Add exclude_secret_chats parameter to clearAllDraftMessages. GitOrigin-RevId: 7b08fe3e954d9e361d7e20c4341575e2101e6dbc --- td/generate/scheme/td_api.tl | 4 ++-- td/generate/scheme/td_api.tlo | Bin 129664 -> 129712 bytes td/telegram/MessagesManager.cpp | 12 +++++++----- td/telegram/MessagesManager.h | 2 +- td/telegram/Td.cpp | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 1af73f74a..54a56d40b 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 4c21404b58e15a330092e07087ef0213bf1a2e2d..0fbac693f5d56e56414037cd71d4109e6a8ba299 100644 GIT binary patch delta 52 zcmZqp%D&+%d&3gOI+oidHh-tH)G;dXGcqtRNI$!;DUw=|oKu=IyY01bN*eE &&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 190ffdca3..729e1e2f0 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 630ed72f6..84c8f2588 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) {