From 44b31537aa4f15c374b37260bd01b2b166297655 Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 29 Feb 2020 21:17:30 +0300 Subject: [PATCH] Add "disable_sent_scheduled_message_notifications" option. GitOrigin-RevId: ad57858024b07b51b89d7b3c28faf20c3e7577da --- td/telegram/MessagesManager.cpp | 12 +++++++++++- td/telegram/Td.cpp | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index dbfd20b2d..b6ce5e69b 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -21410,6 +21410,11 @@ Result MessagesManager::get_messag return Status::Error(406, "Ignore notification in unknown chat"); } + if (is_from_scheduled && dialog_id != get_my_dialog_id() && + G()->shared_config().get_option_boolean("disable_sent_scheduled_message_notifications")) { + return Status::Error("Ignore notification about sent scheduled message"); + } + bool is_new_pinned = is_pinned && message_id.is_valid() && message_id > d->max_notification_message_id; CHECK(!message_id.is_scheduled()); if (message_id.is_valid()) { @@ -22207,6 +22212,10 @@ bool MessagesManager::is_message_notification_disabled(const Dialog *d, const Me if (!has_incoming_notification(d->dialog_id, m) || td_->auth_manager_->is_bot()) { return true; } + if (m->is_from_scheduled && d->dialog_id != get_my_dialog_id() && + G()->shared_config().get_option_boolean("disable_sent_scheduled_message_notifications")) { + return true; + } switch (m->content->get_type()) { case MessageContentType::ChatDeleteHistory: @@ -27265,7 +27274,8 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr } if (old_message->is_from_scheduled != new_message->is_from_scheduled) { - old_message->is_from_scheduled = new_message->is_from_scheduled; + // is_from_scheduled flag shouldn't be changed, because we are unable to show/hide message notification + // old_message->is_from_scheduled = new_message->is_from_scheduled; } if (old_message->edit_date > 0) { diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 9c89c9ebf..fd97fafab 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6718,6 +6718,9 @@ void Td::on_request(uint64 id, td_api::setOption &request) { if (!is_bot && set_boolean_option("disable_contact_registered_notifications")) { return; } + if (!is_bot && set_boolean_option("disable_sent_scheduled_message_notifications")) { + return; + } if (!is_bot && set_boolean_option("disable_top_chats")) { return; }