Change scope mute_until in update_scope_unmute_timeout.
GitOrigin-RevId: 646066978d7bf5f4b2ee98f7e8d84f670e6bfa1f
This commit is contained in:
parent
3e3409ee9b
commit
1e6a2faecb
@ -6666,13 +6666,15 @@ bool MessagesManager::update_dialog_notification_settings(DialogId dialog_id,
|
||||
LOG_CHECK(d != nullptr) << "Wrong " << dialog_id << " in update_dialog_notification_settings";
|
||||
bool was_muted = is_dialog_muted(d);
|
||||
bool was_dialog_mentions_disabled = is_dialog_mention_notifications_disabled(d);
|
||||
update_dialog_unmute_timeout(d, current_settings->use_default_mute_until, current_settings->mute_until,
|
||||
new_settings.use_default_mute_until, new_settings.mute_until);
|
||||
on_dialog_updated(dialog_id, "update_dialog_notification_settings");
|
||||
|
||||
VLOG(notifications) << "Update notification settings in " << dialog_id << " from " << *current_settings << " to "
|
||||
<< new_settings;
|
||||
|
||||
update_dialog_unmute_timeout(d, current_settings->use_default_mute_until, current_settings->mute_until,
|
||||
new_settings.use_default_mute_until, new_settings.mute_until);
|
||||
|
||||
*current_settings = new_settings;
|
||||
on_dialog_updated(dialog_id, "update_dialog_notification_settings");
|
||||
|
||||
if (!was_muted && is_dialog_muted(d)) {
|
||||
remove_all_dialog_notifications(d, false, "update_dialog_notification_settings 2");
|
||||
@ -6721,6 +6723,9 @@ bool MessagesManager::update_scope_notification_settings(NotificationSettingsSco
|
||||
if (is_changed) {
|
||||
save_scope_notification_settings(scope, new_settings);
|
||||
|
||||
VLOG(notifications) << "Update notification settings in " << scope << " from " << *current_settings << " to "
|
||||
<< new_settings;
|
||||
|
||||
update_scope_unmute_timeout(scope, current_settings->mute_until, new_settings.mute_until);
|
||||
|
||||
if (!current_settings->disable_pinned_message_notifications && new_settings.disable_pinned_message_notifications) {
|
||||
@ -6749,8 +6754,6 @@ bool MessagesManager::update_scope_notification_settings(NotificationSettingsSco
|
||||
}
|
||||
}
|
||||
|
||||
VLOG(notifications) << "Update notification settings in " << scope << " from " << *current_settings << " to "
|
||||
<< new_settings;
|
||||
*current_settings = new_settings;
|
||||
|
||||
send_closure(G()->td(), &Td::send_update, get_update_scope_notification_settings_object(scope));
|
||||
@ -6778,10 +6781,11 @@ void MessagesManager::update_dialog_unmute_timeout(Dialog *d, bool old_use_defau
|
||||
return;
|
||||
}
|
||||
CHECK(d != nullptr);
|
||||
CHECK(old_mute_until >= 0);
|
||||
|
||||
schedule_dialog_unmute(d->dialog_id, new_use_default, new_mute_until);
|
||||
|
||||
if (old_mute_until != -1 && need_unread_counter(d->order)) {
|
||||
if (need_unread_counter(d->order)) {
|
||||
auto unread_count = d->server_unread_count + d->local_unread_count;
|
||||
if (old_use_default || new_use_default) {
|
||||
auto scope_mute_until = get_scope_mute_until(d->dialog_id);
|
||||
@ -6826,7 +6830,7 @@ void MessagesManager::schedule_scope_unmute(NotificationSettingsScope scope, int
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::update_scope_unmute_timeout(NotificationSettingsScope scope, int32 old_mute_until,
|
||||
void MessagesManager::update_scope_unmute_timeout(NotificationSettingsScope scope, int32 &old_mute_until,
|
||||
int32 new_mute_until) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
// just in case
|
||||
@ -6837,10 +6841,10 @@ void MessagesManager::update_scope_unmute_timeout(NotificationSettingsScope scop
|
||||
if (old_mute_until == new_mute_until) {
|
||||
return;
|
||||
}
|
||||
CHECK(old_mute_until >= 0);
|
||||
|
||||
schedule_scope_unmute(scope, new_mute_until);
|
||||
|
||||
if (old_mute_until != -1) {
|
||||
auto was_muted = old_mute_until != 0;
|
||||
auto is_muted = new_mute_until != 0;
|
||||
if (was_muted != is_muted) {
|
||||
@ -6892,8 +6896,10 @@ void MessagesManager::update_scope_unmute_timeout(NotificationSettingsScope scop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!dialog_filters_.empty()) {
|
||||
old_mute_until = new_mute_until;
|
||||
if (was_muted != is_muted && !dialog_filters_.empty()) {
|
||||
for (auto &dialog : dialogs_) {
|
||||
Dialog *d = dialog.second.get();
|
||||
if (d->order != DEFAULT_ORDER && d->notification_settings.use_default_mute_until &&
|
||||
@ -6902,8 +6908,6 @@ void MessagesManager::update_scope_unmute_timeout(NotificationSettingsScope scop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::on_dialog_unmute(DialogId dialog_id) {
|
||||
@ -6931,8 +6935,8 @@ void MessagesManager::on_dialog_unmute(DialogId dialog_id) {
|
||||
}
|
||||
|
||||
LOG(INFO) << "Unmute " << dialog_id;
|
||||
update_dialog_unmute_timeout(d, false, d->notification_settings.mute_until, false, 0);
|
||||
d->notification_settings.mute_until = 0;
|
||||
update_dialog_unmute_timeout(d, d->notification_settings.use_default_mute_until, d->notification_settings.mute_until,
|
||||
false, 0);
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateChatNotificationSettings>(
|
||||
dialog_id.get(), get_chat_notification_settings_object(&d->notification_settings)));
|
||||
@ -6962,7 +6966,6 @@ void MessagesManager::on_scope_unmute(NotificationSettingsScope scope) {
|
||||
|
||||
LOG(INFO) << "Unmute " << scope;
|
||||
update_scope_unmute_timeout(scope, notification_settings->mute_until, 0);
|
||||
notification_settings->mute_until = 0;
|
||||
send_closure(G()->td(), &Td::send_update, get_update_scope_notification_settings_object(scope));
|
||||
save_scope_notification_settings(scope, *notification_settings);
|
||||
}
|
||||
|
@ -2177,7 +2177,7 @@ class MessagesManager : public Actor {
|
||||
|
||||
void schedule_scope_unmute(NotificationSettingsScope scope, int32 mute_until);
|
||||
|
||||
void update_scope_unmute_timeout(NotificationSettingsScope scope, int32 old_mute_until, int32 new_mute_until);
|
||||
void update_scope_unmute_timeout(NotificationSettingsScope scope, int32 &old_mute_until, int32 new_mute_until);
|
||||
|
||||
void on_dialog_unmute(DialogId dialog_id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user