Fix notifications settings of newly created chats.

This commit is contained in:
levlam 2022-04-08 18:08:06 +03:00
parent cb5fe8c7cd
commit b3a0c1dcda
2 changed files with 8 additions and 4 deletions

View File

@ -20400,8 +20400,7 @@ DialogId MessagesManager::create_new_group_chat(const vector<UserId> &user_ids,
created_dialogs_.erase(it); created_dialogs_.erase(it);
// set default notification settings to newly created chat // set default notification settings to newly created chat
on_update_dialog_notify_settings(dialog_id, make_tl_object<telegram_api::peerNotifySettings>(), on_update_dialog_notify_settings(dialog_id, nullptr, "create_new_group_chat");
"create_new_group_chat");
promise.set_value(Unit()); promise.set_value(Unit());
return dialog_id; return dialog_id;
@ -20454,8 +20453,7 @@ DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_m
created_dialogs_.erase(it); created_dialogs_.erase(it);
// set default notification settings to newly created chat // set default notification settings to newly created chat
on_update_dialog_notify_settings(dialog_id, make_tl_object<telegram_api::peerNotifySettings>(), on_update_dialog_notify_settings(dialog_id, nullptr, "create_new_channel_chat");
"create_new_channel_chat");
promise.set_value(Unit()); promise.set_value(Unit());
return dialog_id; return dialog_id;

View File

@ -176,6 +176,9 @@ DialogNotificationSettings get_dialog_notification_settings(tl_object_ptr<telegr
bool old_disable_pinned_message_notifications, bool old_disable_pinned_message_notifications,
bool old_use_default_disable_mention_notifications, bool old_use_default_disable_mention_notifications,
bool old_disable_mention_notifications) { bool old_disable_mention_notifications) {
if (settings == nullptr) {
return DialogNotificationSettings();
}
bool use_default_mute_until = (settings->flags_ & telegram_api::peerNotifySettings::MUTE_UNTIL_MASK) == 0; bool use_default_mute_until = (settings->flags_ & telegram_api::peerNotifySettings::MUTE_UNTIL_MASK) == 0;
bool use_default_sound = settings->other_sound_ == nullptr; bool use_default_sound = settings->other_sound_ == nullptr;
bool use_default_show_preview = (settings->flags_ & telegram_api::peerNotifySettings::SHOW_PREVIEWS_MASK) == 0; bool use_default_show_preview = (settings->flags_ & telegram_api::peerNotifySettings::SHOW_PREVIEWS_MASK) == 0;
@ -199,6 +202,9 @@ DialogNotificationSettings get_dialog_notification_settings(tl_object_ptr<telegr
ScopeNotificationSettings get_scope_notification_settings(tl_object_ptr<telegram_api::peerNotifySettings> &&settings, ScopeNotificationSettings get_scope_notification_settings(tl_object_ptr<telegram_api::peerNotifySettings> &&settings,
bool old_disable_pinned_message_notifications, bool old_disable_pinned_message_notifications,
bool old_disable_mention_notifications) { bool old_disable_mention_notifications) {
if (settings == nullptr) {
return ScopeNotificationSettings();
}
auto mute_until = (settings->flags_ & telegram_api::peerNotifySettings::MUTE_UNTIL_MASK) == 0 || auto mute_until = (settings->flags_ & telegram_api::peerNotifySettings::MUTE_UNTIL_MASK) == 0 ||
settings->mute_until_ <= G()->unix_time() settings->mute_until_ <= G()->unix_time()
? 0 ? 0