Do not allow recursive call to set_dialog_pinned_message_notification.
GitOrigin-RevId: 91db05f21ec2feb322efa9c9be5aa76b9f49ad3f
This commit is contained in:
parent
3cc0e05af6
commit
ac60ef4c5a
@ -10532,15 +10532,14 @@ void MessagesManager::set_dialog_pinned_message_notification(Dialog *d, MessageI
|
|||||||
if (old_message_id.is_valid()) {
|
if (old_message_id.is_valid()) {
|
||||||
auto m = get_message_force(d, old_message_id, "set_dialog_pinned_message_notification");
|
auto m = get_message_force(d, old_message_id, "set_dialog_pinned_message_notification");
|
||||||
if (m != nullptr && m->notification_id.is_valid() && is_message_notification_active(d, m)) {
|
if (m != nullptr && m->notification_id.is_valid() && is_message_notification_active(d, m)) {
|
||||||
// Because we removing pinned message notification it will call set_dialog_pinned_message_notification recursively
|
// Can't remove pinned_message_notification_message_id before the call,
|
||||||
// after m->notification_id is removed, so everything will work. Can't remove pinned_message_notification_message_id
|
// because the notification needs to be still active inside remove_message_notification_id
|
||||||
// before the call, because the notification needs to be still active inside remove_message_notification_id
|
remove_message_notification_id(d, m, true, false, true);
|
||||||
remove_message_notification_id(d, m, true, false);
|
|
||||||
on_message_changed(d, m, false, "set_dialog_pinned_message_notification");
|
on_message_changed(d, m, false, "set_dialog_pinned_message_notification");
|
||||||
} else {
|
} else {
|
||||||
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
|
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
|
||||||
d->mention_notification_group.group_id, old_message_id, false,
|
d->mention_notification_group.group_id, old_message_id, false,
|
||||||
"set_dialog_pinned_message_notification");
|
"set_dialog_pinned_message_notification 2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d->pinned_message_notification_message_id = message_id;
|
d->pinned_message_notification_message_id = message_id;
|
||||||
@ -11117,7 +11116,8 @@ void MessagesManager::delete_notification_id_to_message_id_correspondence(Dialog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::remove_message_notification_id(Dialog *d, Message *m, bool is_permanent, bool force_update) {
|
void MessagesManager::remove_message_notification_id(Dialog *d, Message *m, bool is_permanent, bool force_update,
|
||||||
|
bool ignore_pinned_message_notification_removal) {
|
||||||
CHECK(d != nullptr);
|
CHECK(d != nullptr);
|
||||||
CHECK(m != nullptr);
|
CHECK(m != nullptr);
|
||||||
if (!m->notification_id.is_valid()) {
|
if (!m->notification_id.is_valid()) {
|
||||||
@ -11139,7 +11139,8 @@ void MessagesManager::remove_message_notification_id(Dialog *d, Message *m, bool
|
|||||||
delete_notification_id_to_message_id_correspondence(d, notification_id, m->message_id);
|
delete_notification_id_to_message_id_correspondence(d, notification_id, m->message_id);
|
||||||
m->removed_notification_id = m->notification_id;
|
m->removed_notification_id = m->notification_id;
|
||||||
m->notification_id = NotificationId();
|
m->notification_id = NotificationId();
|
||||||
if (d->pinned_message_notification_message_id == m->message_id && is_permanent) {
|
if (d->pinned_message_notification_message_id == m->message_id && is_permanent &&
|
||||||
|
!ignore_pinned_message_notification_removal) {
|
||||||
remove_dialog_pinned_message_notification(d); // must be called after notification_id is removed
|
remove_dialog_pinned_message_notification(d); // must be called after notification_id is removed
|
||||||
}
|
}
|
||||||
if (group_info.last_notification_id == notification_id) {
|
if (group_info.last_notification_id == notification_id) {
|
||||||
@ -19415,11 +19416,11 @@ MessagesManager::MessageNotificationGroup MessagesManager::get_message_notificat
|
|||||||
auto &group_info = from_mentions ? d->mention_notification_group : d->message_notification_group;
|
auto &group_info = from_mentions ? d->mention_notification_group : d->message_notification_group;
|
||||||
|
|
||||||
MessageNotificationGroup result;
|
MessageNotificationGroup result;
|
||||||
VLOG(notifications) << "Found " << group_info.group_id << '/' << d->dialog_id << " by " << group_id << " with "
|
VLOG(notifications) << "Found " << (from_mentions ? "Mentions " : "Messages ") << group_info.group_id << '/'
|
||||||
<< d->unread_mention_count << " unread mentions, pinned "
|
<< d->dialog_id << " by " << group_id << " with " << d->unread_mention_count
|
||||||
<< d->pinned_message_notification_message_id << ", new secret chat "
|
<< " unread mentions, pinned " << d->pinned_message_notification_message_id
|
||||||
<< d->new_secret_chat_notification_id << " and " << d->server_unread_count + d->local_unread_count
|
<< ", new secret chat " << d->new_secret_chat_notification_id << " and "
|
||||||
<< " unread messages";
|
<< d->server_unread_count + d->local_unread_count << " unread messages";
|
||||||
result.dialog_id = d->dialog_id;
|
result.dialog_id = d->dialog_id;
|
||||||
result.total_count = get_dialog_pending_notification_count(d, from_mentions);
|
result.total_count = get_dialog_pending_notification_count(d, from_mentions);
|
||||||
auto pending_notification_count =
|
auto pending_notification_count =
|
||||||
|
@ -1630,7 +1630,8 @@ class MessagesManager : public Actor {
|
|||||||
static void delete_notification_id_to_message_id_correspondence(Dialog *d, NotificationId notification_id,
|
static void delete_notification_id_to_message_id_correspondence(Dialog *d, NotificationId notification_id,
|
||||||
MessageId message_id);
|
MessageId message_id);
|
||||||
|
|
||||||
void remove_message_notification_id(Dialog *d, Message *m, bool is_permanent, bool force_update);
|
void remove_message_notification_id(Dialog *d, Message *m, bool is_permanent, bool force_update,
|
||||||
|
bool ignore_pinned_message_notification_removal = false);
|
||||||
|
|
||||||
void remove_new_secret_chat_notification(Dialog *d, bool is_permanent);
|
void remove_new_secret_chat_notification(Dialog *d, bool is_permanent);
|
||||||
|
|
||||||
|
@ -1804,8 +1804,8 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti
|
|||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
VLOG(notifications) << "Remove " << notification_id << " from " << group_id << " with force_update = " << force_update
|
VLOG(notifications) << "Remove " << notification_id << " from " << group_id << " with is_permanent = " << is_permanent
|
||||||
<< " from " << source;
|
<< ", force_update = " << force_update << " from " << source;
|
||||||
|
|
||||||
auto group_it = get_group_force(group_id);
|
auto group_it = get_group_force(group_id);
|
||||||
if (group_it == groups_.end()) {
|
if (group_it == groups_.end()) {
|
||||||
|
Reference in New Issue
Block a user