From 8b233484e0e5d0b822e33c3d5c5bdf02f60007d7 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 18 Feb 2019 02:41:53 +0300 Subject: [PATCH] Do not copy show_preview notification setting to secret chats. GitOrigin-RevId: 5c02532e5dbd26d1e5d8f9e9afee44ae33b65784 --- td/telegram/MessagesManager.cpp | 16 ++++++++++++++-- td/telegram/NotificationSettings.h | 1 + td/telegram/NotificationSettings.hpp | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 8deb1e8c..41f39cf6 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17817,7 +17817,7 @@ NotificationGroupId MessagesManager::get_dialog_notification_group_id(DialogId d } while (get_message_notification_group_force(next_notification_group_id).dialog_id.is_valid()); group_info.group_id = next_notification_group_id; group_info.is_changed = true; - VLOG(notifications) << "Assign " << next_notification_group_id << " to " << group_info.group_id << '/' << dialog_id; + VLOG(notifications) << "Assign " << next_notification_group_id << " to " << dialog_id; on_dialog_updated(dialog_id, "get_dialog_notification_group_id"); notification_group_id_to_dialog_id_.emplace(next_notification_group_id, dialog_id); @@ -22570,7 +22570,11 @@ void MessagesManager::force_create_dialog(DialogId dialog_id, const char *source Dialog *user_d = get_dialog_force(DialogId(user_id)); if (user_d != nullptr && user_d->notification_settings.is_synchronized) { VLOG(notifications) << "Copy notification settings from " << user_d->dialog_id << " to " << dialog_id; - update_dialog_notification_settings(dialog_id, &d->notification_settings, user_d->notification_settings); + auto new_notification_settings = user_d->notification_settings; + new_notification_settings.use_default_show_preview = true; + new_notification_settings.show_preview = false; + new_notification_settings.is_secret_chat_show_preview_fixed = true; + update_dialog_notification_settings(dialog_id, &d->notification_settings, new_notification_settings); } } else { LOG(ERROR) << "Found previously created secret " << d->dialog_id << ", when creating it from " << source; @@ -22679,6 +22683,14 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr &&d, } } + if (!d->notification_settings.is_secret_chat_show_preview_fixed && + d->dialog_id.get_type() == DialogType::SecretChat) { + d->notification_settings.use_default_show_preview = true; + d->notification_settings.show_preview = false; + d->notification_settings.is_secret_chat_show_preview_fixed = true; + on_dialog_updated(d->dialog_id, "fix secret chat show preview"); + } + d->have_full_history = true; d->need_restore_reply_markup = false; d->is_last_read_inbox_message_id_inited = true; diff --git a/td/telegram/NotificationSettings.h b/td/telegram/NotificationSettings.h index 05c5e722..2ff3bdb4 100644 --- a/td/telegram/NotificationSettings.h +++ b/td/telegram/NotificationSettings.h @@ -25,6 +25,7 @@ class DialogNotificationSettings { bool use_default_sound = true; bool use_default_show_preview = true; bool is_use_default_fixed = true; + bool is_secret_chat_show_preview_fixed = false; bool is_synchronized = false; // local settings diff --git a/td/telegram/NotificationSettings.hpp b/td/telegram/NotificationSettings.hpp index af5b7ee4..7f05ebe1 100644 --- a/td/telegram/NotificationSettings.hpp +++ b/td/telegram/NotificationSettings.hpp @@ -32,6 +32,7 @@ void store(const DialogNotificationSettings ¬ification_settings, StorerT &sto STORE_FLAG(notification_settings.disable_pinned_message_notifications); STORE_FLAG(!notification_settings.use_default_disable_mention_notifications); STORE_FLAG(notification_settings.disable_mention_notifications); + STORE_FLAG(notification_settings.is_secret_chat_show_preview_fixed); END_STORE_FLAGS(); if (is_muted) { store(notification_settings.mute_until, storer); @@ -61,6 +62,7 @@ void parse(DialogNotificationSettings ¬ification_settings, ParserT &parser) { PARSE_FLAG(notification_settings.disable_pinned_message_notifications); PARSE_FLAG(use_disable_mention_notifications); PARSE_FLAG(notification_settings.disable_mention_notifications); + PARSE_FLAG(notification_settings.is_secret_chat_show_preview_fixed); END_PARSE_FLAGS(); notification_settings.use_default_disable_pinned_message_notifications = !use_disable_pinned_message_notifications; notification_settings.use_default_disable_mention_notifications = !use_disable_mention_notifications;