Simplify usage of remove_message_notification_id.
GitOrigin-RevId: 0538d4d965d93cc087955cb09b2eccbd564e780d
This commit is contained in:
parent
d069c6cf0e
commit
6938d286e5
@ -5096,11 +5096,7 @@ bool MessagesManager::update_message_contains_unread_mention(Dialog *d, Message
|
|||||||
LOG(INFO) << "Update unread mention message count in " << d->dialog_id << " to " << d->unread_mention_count
|
LOG(INFO) << "Update unread mention message count in " << d->dialog_id << " to " << d->unread_mention_count
|
||||||
<< " by reading " << m->message_id << " from " << source;
|
<< " by reading " << m->message_id << " from " << source;
|
||||||
|
|
||||||
if (m->notification_id.is_valid() && d->message_notification_group_id.is_valid()) {
|
remove_message_notification_id(d, m, true);
|
||||||
remove_message_notification_id(d, m);
|
|
||||||
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification,
|
|
||||||
d->message_notification_group_id, m->notification_id, true, Promise<Unit>());
|
|
||||||
}
|
|
||||||
|
|
||||||
send_closure(G()->td(), &Td::send_update,
|
send_closure(G()->td(), &Td::send_update,
|
||||||
make_tl_object<td_api::updateMessageMentionRead>(d->dialog_id.get(), m->message_id.get(),
|
make_tl_object<td_api::updateMessageMentionRead>(d->dialog_id.get(), m->message_id.get(),
|
||||||
@ -7837,11 +7833,7 @@ void MessagesManager::read_all_dialog_mentions(DialogId dialog_id, Promise<Unit>
|
|||||||
CHECK(m->message_id == message_id);
|
CHECK(m->message_id == message_id);
|
||||||
m->contains_unread_mention = false;
|
m->contains_unread_mention = false;
|
||||||
|
|
||||||
if (m->notification_id.is_valid() && d->message_notification_group_id.is_valid()) {
|
remove_message_notification_id(d, m, true);
|
||||||
remove_message_notification_id(d, m);
|
|
||||||
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification,
|
|
||||||
d->message_notification_group_id, m->notification_id, true, Promise<Unit>());
|
|
||||||
}
|
|
||||||
send_closure(G()->td(), &Td::send_update,
|
send_closure(G()->td(), &Td::send_update,
|
||||||
make_tl_object<td_api::updateMessageMentionRead>(dialog_id.get(), m->message_id.get(), 0));
|
make_tl_object<td_api::updateMessageMentionRead>(dialog_id.get(), m->message_id.get(), 0));
|
||||||
is_update_sent = true;
|
is_update_sent = true;
|
||||||
@ -10340,15 +10332,24 @@ void MessagesManager::delete_notification_id_to_message_id_correspondence(Dialog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::remove_message_notification_id(Dialog *d, Message *m) {
|
void MessagesManager::remove_message_notification_id(Dialog *d, Message *m, bool is_permanent) {
|
||||||
CHECK(d != nullptr);
|
CHECK(d != nullptr);
|
||||||
CHECK(m != nullptr);
|
CHECK(m != nullptr);
|
||||||
CHECK(d->message_notification_group_id.is_valid());
|
if (!m->notification_id.is_valid() || !d->message_notification_group_id.is_valid()) {
|
||||||
CHECK(m->notification_id.is_valid());
|
return;
|
||||||
VLOG(notifications) << "Remove " << m->notification_id << " from " << m->message_id << " in " << d->dialog_id
|
}
|
||||||
|
|
||||||
|
auto notification_id = m->notification_id;
|
||||||
|
VLOG(notifications) << "Remove " << notification_id << " from " << m->message_id << " in " << d->dialog_id
|
||||||
<< " from database";
|
<< " from database";
|
||||||
delete_notification_id_to_message_id_correspondence(d, m->notification_id, m->message_id);
|
delete_notification_id_to_message_id_correspondence(d, notification_id, m->message_id);
|
||||||
m->notification_id = NotificationId();
|
m->notification_id = NotificationId();
|
||||||
|
if (is_permanent) {
|
||||||
|
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification,
|
||||||
|
d->message_notification_group_id, notification_id, true, Promise<Unit>());
|
||||||
|
} else {
|
||||||
|
on_message_changed(d, m, false, "remove_message_notification_id");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DO NOT FORGET TO ADD ALL CHANGES OF THIS FUNCTION AS WELL TO do_delete_all_dialog_messages
|
// DO NOT FORGET TO ADD ALL CHANGES OF THIS FUNCTION AS WELL TO do_delete_all_dialog_messages
|
||||||
@ -17609,7 +17610,7 @@ void MessagesManager::remove_message_notification(DialogId dialog_id, Notificati
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (notification_id == NotificationId::max()) {
|
if (notification_id == NotificationId::max()) {
|
||||||
return; // there can be nonotification with this ID
|
return; // there can be no notification with this ID
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = d->notification_id_to_message_id.find(notification_id);
|
auto it = d->notification_id_to_message_id.find(notification_id);
|
||||||
@ -17618,8 +17619,7 @@ void MessagesManager::remove_message_notification(DialogId dialog_id, Notificati
|
|||||||
CHECK(m != nullptr);
|
CHECK(m != nullptr);
|
||||||
CHECK(m->notification_id == notification_id);
|
CHECK(m->notification_id == notification_id);
|
||||||
if (m->message_id.get() > d->last_read_inbox_message_id.get() || m->contains_unread_mention) {
|
if (m->message_id.get() > d->last_read_inbox_message_id.get() || m->contains_unread_mention) {
|
||||||
remove_message_notification_id(d, m);
|
remove_message_notification_id(d, m, false);
|
||||||
on_message_changed(d, m, false, "remove_message_notification");
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -17651,10 +17651,8 @@ void MessagesManager::do_remove_message_notification(DialogId dialog_id, Notific
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto m = on_get_message_from_database(dialog_id, d, std::move(result[0]));
|
auto m = on_get_message_from_database(dialog_id, d, std::move(result[0]));
|
||||||
if (m != nullptr && m->notification_id.is_valid() &&
|
if (m != nullptr && (m->message_id.get() > d->last_read_inbox_message_id.get() || m->contains_unread_mention)) {
|
||||||
(m->message_id.get() > d->last_read_inbox_message_id.get() || m->contains_unread_mention)) {
|
remove_message_notification_id(d, m, false);
|
||||||
remove_message_notification_id(d, m);
|
|
||||||
on_message_changed(d, m, false, "do_remove_message_notification");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1460,7 +1460,7 @@ 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);
|
||||||
|
|
||||||
static void remove_message_notification_id(Dialog *d, Message *m);
|
void remove_message_notification_id(Dialog *d, Message *m, bool is_permanent);
|
||||||
|
|
||||||
void do_delete_message_logevent(const DeleteMessageLogEvent &logevent) const;
|
void do_delete_message_logevent(const DeleteMessageLogEvent &logevent) const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user