From b6233576951bb8dea55624cf990933f862e8c920 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 15 Nov 2018 19:09:01 +0300 Subject: [PATCH] Disable delay for call and new secret chat notifications. GitOrigin-RevId: a2c4baa804c84503c7c073dc1b6efae6d0590bc1 --- td/telegram/NotificationManager.cpp | 3 +++ td/telegram/NotificationType.cpp | 12 ++++++++++++ td/telegram/NotificationType.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 00a51751..e4daf1d0 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -116,6 +116,9 @@ int32 NotificationManager::get_notification_delay_ms(DialogId dialog_id, if (dialog_id.get_type() == DialogType::SecretChat) { return 0; // there is no reason to delay notifications in secret chats } + if (!notification.type->can_be_delayed()) { + return 0; + } auto online_info = td_->contacts_manager_->get_my_online_status(); if (!online_info.is_online_local && online_info.is_online_remote) { diff --git a/td/telegram/NotificationType.cpp b/td/telegram/NotificationType.cpp index 7a129edf..1db55aef 100644 --- a/td/telegram/NotificationType.cpp +++ b/td/telegram/NotificationType.cpp @@ -12,6 +12,10 @@ namespace td { class NotificationTypeMessage : public NotificationType { + bool can_be_delayed() const override { + return true; + } + td_api::object_ptr get_notification_type_object(DialogId dialog_id) const override { auto message_object = G()->td().get_actor_unsafe()->messages_manager_->get_message_object({dialog_id, message_id_}); if (message_object == nullptr) { @@ -36,6 +40,10 @@ class NotificationTypeMessage : public NotificationType { }; class NotificationTypeSecretChat : public NotificationType { + bool can_be_delayed() const override { + return false; + } + td_api::object_ptr get_notification_type_object(DialogId dialog_id) const override { return td_api::make_object(); } @@ -54,6 +62,10 @@ class NotificationTypeSecretChat : public NotificationType { }; class NotificationTypeCall : public NotificationType { + bool can_be_delayed() const override { + return false; + } + td_api::object_ptr get_notification_type_object(DialogId dialog_id) const override { return td_api::make_object(call_id_.get()); } diff --git a/td/telegram/NotificationType.h b/td/telegram/NotificationType.h index 734f9479..78100467 100644 --- a/td/telegram/NotificationType.h +++ b/td/telegram/NotificationType.h @@ -26,6 +26,8 @@ class NotificationType { virtual ~NotificationType() { } + virtual bool can_be_delayed() const = 0; + virtual td_api::object_ptr get_notification_type_object(DialogId dialog_id) const = 0; virtual StringBuilder &to_string_builder(StringBuilder &string_builder) const = 0;