Disable delay for call and new secret chat notifications.

GitOrigin-RevId: a2c4baa804c84503c7c073dc1b6efae6d0590bc1
This commit is contained in:
levlam 2018-11-15 19:09:01 +03:00
parent a86a9d2a00
commit b623357695
3 changed files with 17 additions and 0 deletions

View File

@ -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) {

View File

@ -12,6 +12,10 @@
namespace td {
class NotificationTypeMessage : public NotificationType {
bool can_be_delayed() const override {
return true;
}
td_api::object_ptr<td_api::NotificationType> 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<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const override {
return td_api::make_object<td_api::notificationTypeNewSecretChat>();
}
@ -54,6 +62,10 @@ class NotificationTypeSecretChat : public NotificationType {
};
class NotificationTypeCall : public NotificationType {
bool can_be_delayed() const override {
return false;
}
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const override {
return td_api::make_object<td_api::notificationTypeNewCall>(call_id_.get());
}

View File

@ -26,6 +26,8 @@ class NotificationType {
virtual ~NotificationType() {
}
virtual bool can_be_delayed() const = 0;
virtual td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const = 0;
virtual StringBuilder &to_string_builder(StringBuilder &string_builder) const = 0;