Improve names of NotificationGroupInfo fields.

This commit is contained in:
levlam 2023-08-21 19:36:43 +03:00
parent 6c4545fb3f
commit 05b1bec6a9
4 changed files with 183 additions and 181 deletions

View File

@ -8094,7 +8094,7 @@ bool MessagesManager::update_dialog_notification_settings(DialogId dialog_id,
remove_all_dialog_notifications(d, false, "update_dialog_notification_settings 2");
}
if (is_dialog_pinned_message_notifications_disabled(d) && d->notification_info != nullptr &&
d->notification_info->mention_notification_group_.group_id.is_valid() &&
d->notification_info->mention_notification_group_.group_id_.is_valid() &&
d->notification_info->pinned_message_notification_message_id_.is_valid()) {
remove_dialog_pinned_message_notification(d, "update_dialog_notification_settings 3");
}
@ -11970,12 +11970,14 @@ void MessagesManager::delete_all_dialog_messages(Dialog *d, bool remove_from_dia
delete_all_dialog_messages_from_database(d, MessageId::max(), "delete_all_dialog_messages 3");
if (d->notification_info != nullptr) {
d->notification_info->message_notification_group_.max_removed_notification_id =
NotificationId(); // it is not needed anymore
d->notification_info->message_notification_group_.max_removed_message_id = MessageId(); // it is not needed anymore
d->notification_info->mention_notification_group_.max_removed_notification_id =
NotificationId(); // it is not needed anymore
d->notification_info->mention_notification_group_.max_removed_message_id = MessageId(); // it is not needed anymore
d->notification_info->message_notification_group_.max_removed_notification_id_ =
NotificationId(); // it is not needed anymore
d->notification_info->message_notification_group_.max_removed_message_id_ =
MessageId(); // it is not needed anymore
d->notification_info->mention_notification_group_.max_removed_notification_id_ =
NotificationId(); // it is not needed anymore
d->notification_info->mention_notification_group_.max_removed_message_id_ =
MessageId(); // it is not needed anymore
d->notification_info->notification_id_to_message_id_.clear();
}
@ -12898,7 +12900,7 @@ void MessagesManager::set_dialog_last_read_inbox_message_id(Dialog *d, MessageId
<< " after updating last read inbox message to " << message_id
<< " and unread message count to " << server_unread_count << " + " << local_unread_count
<< " from " << source;
if (d->notification_info != nullptr && d->notification_info->message_notification_group_.group_id.is_valid()) {
if (d->notification_info != nullptr && d->notification_info->message_notification_group_.group_id_.is_valid()) {
auto total_count = get_dialog_pending_notification_count(d, false);
if (total_count == 0) {
set_dialog_last_notification(d->dialog_id, d->notification_info->message_notification_group_, 0,
@ -12921,12 +12923,12 @@ void MessagesManager::set_dialog_last_read_inbox_message_id(Dialog *d, MessageId
total_count = 0;
}
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification_group,
d->notification_info->message_notification_group_.group_id, NotificationId(),
d->notification_info->message_notification_group_.group_id_, NotificationId(),
d->last_read_inbox_message_id, total_count, Slice(source) == Slice("view_messages"),
Promise<Unit>());
}
if (d->notification_info != nullptr && d->notification_info->mention_notification_group_.group_id.is_valid() &&
if (d->notification_info != nullptr && d->notification_info->mention_notification_group_.group_id_.is_valid() &&
d->notification_info->pinned_message_notification_message_id_.is_valid() &&
d->notification_info->pinned_message_notification_message_id_ <= d->last_read_inbox_message_id) {
// remove pinned message notification when it is read
@ -14028,13 +14030,13 @@ void MessagesManager::on_update_secret_chat_state(SecretChatId secret_chat_id, S
if (d->notification_info->new_secret_chat_notification_id_.is_valid()) {
remove_new_secret_chat_notification(d, true);
}
if (d->notification_info->message_notification_group_.group_id.is_valid() &&
if (d->notification_info->message_notification_group_.group_id_.is_valid() &&
get_dialog_pending_notification_count(d, false) == 0 &&
!d->notification_info->message_notification_group_.last_notification_id.is_valid()) {
!d->notification_info->message_notification_group_.last_notification_id_.is_valid()) {
d->notification_info->message_notification_group_.try_reuse();
on_dialog_updated(d->dialog_id, "on_update_secret_chat_state");
}
CHECK(!d->notification_info->mention_notification_group_.group_id
CHECK(!d->notification_info->mention_notification_group_.group_id_
.is_valid()); // there can't be unread mentions in secret chats
}
}
@ -15323,7 +15325,7 @@ void MessagesManager::set_dialog_pinned_message_notification(Dialog *d, MessageI
on_message_changed(d, m, false, source);
} else {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
notification_info->mention_notification_group_.group_id, old_message_id, false, source);
notification_info->mention_notification_group_.group_id_, old_message_id, false, source);
}
}
notification_info->pinned_message_notification_message_id_ = message_id;
@ -15339,7 +15341,7 @@ void MessagesManager::remove_scope_pinned_message_notifications(NotificationSett
dialogs_.foreach([&](const DialogId &dialog_id, unique_ptr<Dialog> &dialog) {
Dialog *d = dialog.get();
if (d->notification_settings.use_default_disable_pinned_message_notifications && d->notification_info != nullptr &&
d->notification_info->mention_notification_group_.group_id.is_valid() &&
d->notification_info->mention_notification_group_.group_id_.is_valid() &&
d->notification_info->pinned_message_notification_message_id_.is_valid() &&
get_dialog_notification_setting_scope(dialog_id) == scope) {
remove_dialog_pinned_message_notification(d, "remove_scope_pinned_message_notifications");
@ -15367,7 +15369,7 @@ void MessagesManager::remove_dialog_mention_notifications(Dialog *d) {
if (d->notification_info == nullptr) {
return;
}
auto notification_group_id = d->notification_info->mention_notification_group_.group_id;
auto notification_group_id = d->notification_info->mention_notification_group_.group_id_;
if (!notification_group_id.is_valid()) {
return;
}
@ -15418,13 +15420,13 @@ void MessagesManager::remove_dialog_mention_notifications(Dialog *d) {
bool MessagesManager::set_dialog_last_notification(DialogId dialog_id, NotificationGroupInfo &group_info,
int32 last_notification_date, NotificationId last_notification_id,
const char *source) {
if (group_info.last_notification_date != last_notification_date ||
group_info.last_notification_id != last_notification_id) {
VLOG(notifications) << "Set " << group_info.group_id << '/' << dialog_id << " last notification to "
if (group_info.last_notification_date_ != last_notification_date ||
group_info.last_notification_id_ != last_notification_id) {
VLOG(notifications) << "Set " << group_info.group_id_ << '/' << dialog_id << " last notification to "
<< last_notification_id << " sent at " << last_notification_date << " from " << source;
group_info.last_notification_date = last_notification_date;
group_info.last_notification_id = last_notification_id;
group_info.is_changed = true;
group_info.last_notification_date_ = last_notification_date;
group_info.last_notification_id_ = last_notification_id;
group_info.is_changed_ = true;
on_dialog_updated(dialog_id, "set_dialog_last_notification");
return true;
}
@ -16105,14 +16107,14 @@ void MessagesManager::remove_message_notification_id(Dialog *d, Message *m, bool
auto from_mentions = is_from_mention_notification_group(m);
auto &group_info = get_notification_group_info(d, m);
if (!group_info.group_id.is_valid()) {
if (!group_info.group_id_.is_valid()) {
return;
}
bool had_active_notification = is_message_notification_active(d, m);
auto notification_id = m->notification_id;
VLOG(notifications) << "Remove " << notification_id << " from " << m->message_id << " in " << group_info.group_id
VLOG(notifications) << "Remove " << notification_id << " from " << m->message_id << " in " << group_info.group_id_
<< '/' << d->dialog_id << " from database, was_active = " << had_active_notification
<< ", is_permanent = " << is_permanent;
delete_notification_id_to_message_id_correspondence(d->notification_info.get(), notification_id, m->message_id);
@ -16123,14 +16125,14 @@ void MessagesManager::remove_message_notification_id(Dialog *d, Message *m, bool
remove_dialog_pinned_message_notification(
d, "remove_message_notification_id"); // must be called after notification_id is removed
}
if (group_info.last_notification_id == notification_id) {
if (group_info.last_notification_id_ == notification_id) {
// last notification is deleted, need to find new last notification
fix_dialog_last_notification_id(d, from_mentions, m->message_id);
}
if (is_permanent) {
if (had_active_notification) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification, group_info.group_id,
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification, group_info.group_id_,
notification_id, is_permanent, force_update, Promise<Unit>(),
"remove_message_notification_id");
}
@ -16148,15 +16150,15 @@ void MessagesManager::remove_new_secret_chat_notification(Dialog *d, bool is_per
auto notification_id = d->notification_info->new_secret_chat_notification_id_;
CHECK(notification_id.is_valid());
VLOG(notifications) << "Remove " << notification_id << " about new secret " << d->dialog_id << " from "
<< d->notification_info->message_notification_group_.group_id;
<< d->notification_info->message_notification_group_.group_id_;
d->notification_info->new_secret_chat_notification_id_ = NotificationId();
bool is_fixed = set_dialog_last_notification(d->dialog_id, d->notification_info->message_notification_group_, 0,
NotificationId(), "remove_new_secret_chat_notification");
CHECK(is_fixed);
if (is_permanent) {
CHECK(d->notification_info->message_notification_group_.group_id.is_valid());
CHECK(d->notification_info->message_notification_group_.group_id_.is_valid());
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification,
d->notification_info->message_notification_group_.group_id, notification_id, true, true,
d->notification_info->message_notification_group_.group_id_, notification_id, true, true,
Promise<Unit>(), "remove_new_secret_chat_notification");
}
}
@ -16170,8 +16172,8 @@ void MessagesManager::fix_dialog_last_notification_id(Dialog *d, bool from_menti
CHECK(!td_->auth_manager_->is_bot());
auto it = d->ordered_messages.get_const_iterator(message_id);
auto &group_info = get_notification_group_info(d, from_mentions);
VLOG(notifications) << "Trying to fix last notification identifier in " << group_info.group_id << " from "
<< d->dialog_id << " from " << message_id << "/" << group_info.last_notification_id;
VLOG(notifications) << "Trying to fix last notification identifier in " << group_info.group_id_ << " from "
<< d->dialog_id << " from " << message_id << "/" << group_info.last_notification_id_;
if (*it != nullptr && ((*it)->get_message_id() == message_id || (*it)->have_next())) {
while (*it != nullptr) {
const Message *m = get_message(d, (*it)->get_message_id());
@ -16187,10 +16189,10 @@ void MessagesManager::fix_dialog_last_notification_id(Dialog *d, bool from_menti
}
if (G()->use_message_database()) {
get_message_notifications_from_database(
d->dialog_id, group_info.group_id, group_info.last_notification_id, message_id, 1,
d->dialog_id, group_info.group_id_, group_info.last_notification_id_, message_id, 1,
PromiseCreator::lambda(
[actor_id = actor_id(this), dialog_id = d->dialog_id, from_mentions,
prev_last_notification_id = group_info.last_notification_id](Result<vector<Notification>> result) {
prev_last_notification_id = group_info.last_notification_id_](Result<vector<Notification>> result) {
send_closure(actor_id, &MessagesManager::do_fix_dialog_last_notification_id, dialog_id, from_mentions,
prev_last_notification_id, std::move(result));
}));
@ -16210,9 +16212,9 @@ void MessagesManager::do_fix_dialog_last_notification_id(DialogId dialog_id, boo
return;
}
auto &group_info = get_notification_group_info(d, from_mentions);
VLOG(notifications) << "Receive " << result.ok().size() << " message notifications in " << group_info.group_id << '/'
VLOG(notifications) << "Receive " << result.ok().size() << " message notifications in " << group_info.group_id_ << '/'
<< dialog_id << " from " << prev_last_notification_id;
if (group_info.last_notification_id != prev_last_notification_id) {
if (group_info.last_notification_id_ != prev_last_notification_id) {
// last_notification_id was changed
return;
}
@ -28886,7 +28888,7 @@ NotificationGroupId MessagesManager::get_dialog_notification_group_id(DialogId d
// just in case
return NotificationGroupId();
}
if (!group_info.group_id.is_valid()) {
if (!group_info.group_id_.is_valid()) {
NotificationGroupId next_notification_group_id;
do {
next_notification_group_id = td_->notification_manager_->get_next_notification_group_id();
@ -28894,8 +28896,8 @@ NotificationGroupId MessagesManager::get_dialog_notification_group_id(DialogId d
return NotificationGroupId();
}
} 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;
group_info.group_id_ = next_notification_group_id;
group_info.is_changed_ = true;
VLOG(notifications) << "Assign " << next_notification_group_id << " to " << dialog_id;
on_dialog_updated(dialog_id, "get_dialog_notification_group_id");
@ -28907,13 +28909,13 @@ NotificationGroupId MessagesManager::get_dialog_notification_group_id(DialogId d
}
}
CHECK(group_info.group_id.is_valid());
CHECK(group_info.group_id_.is_valid());
// notification group must be preloaded to guarantee that there is no race between
// get_message_notifications_from_database_force and new notifications added right now
td_->notification_manager_->load_group_force(group_info.group_id);
td_->notification_manager_->load_group_force(group_info.group_id_);
return group_info.group_id;
return group_info.group_id_;
}
Result<MessagesManager::MessagePushNotificationInfo> MessagesManager::get_message_push_notification_info(
@ -29048,11 +29050,11 @@ NotificationId MessagesManager::get_next_notification_id(NotificationInfo *notif
}
} while (notification_info->notification_id_to_message_id_.count(notification_id) != 0 ||
notification_info->new_secret_chat_notification_id_ == notification_id ||
notification_id.get() <= notification_info->message_notification_group_.last_notification_id.get() ||
notification_id.get() <= notification_info->message_notification_group_.max_removed_notification_id.get() ||
notification_id.get() <= notification_info->mention_notification_group_.last_notification_id.get() ||
notification_id.get() <= notification_info->message_notification_group_.last_notification_id_.get() ||
notification_id.get() <= notification_info->message_notification_group_.max_removed_notification_id_.get() ||
notification_id.get() <= notification_info->mention_notification_group_.last_notification_id_.get() ||
notification_id.get() <=
notification_info->mention_notification_group_.max_removed_notification_id.get()); // just in case
notification_info->mention_notification_group_.max_removed_notification_id_.get()); // just in case
if (message_id.is_valid()) {
add_notification_id_to_message_id_correspondence(notification_info, notification_id, message_id);
}
@ -29085,28 +29087,28 @@ MessagesManager::MessageNotificationGroup MessagesManager::get_message_notificat
if (d == nullptr || d->notification_info == nullptr) {
return MessageNotificationGroup();
}
if (d->notification_info->message_notification_group_.group_id != group_id &&
d->notification_info->mention_notification_group_.group_id != group_id) {
if (d->notification_info->message_notification_group_.group_id_ != group_id &&
d->notification_info->mention_notification_group_.group_id_ != group_id) {
if (d->dialog_id.get_type() == DialogType::SecretChat &&
!d->notification_info->message_notification_group_.group_id.is_valid() &&
!d->notification_info->mention_notification_group_.group_id.is_valid()) {
!d->notification_info->message_notification_group_.group_id_.is_valid() &&
!d->notification_info->mention_notification_group_.group_id_.is_valid()) {
// the group was reused, but wasn't deleted from the database, trying to resave it
auto &group_info = d->notification_info->message_notification_group_;
group_info.group_id = group_id;
group_info.group_id_ = group_id;
group_info.try_reuse();
save_dialog_to_database(d->dialog_id);
group_info = NotificationGroupInfo();
}
}
LOG_CHECK(d->notification_info->message_notification_group_.group_id == group_id ||
d->notification_info->mention_notification_group_.group_id == group_id);
LOG_CHECK(d->notification_info->message_notification_group_.group_id_ == group_id ||
d->notification_info->mention_notification_group_.group_id_ == group_id);
bool from_mentions = d->notification_info->mention_notification_group_.group_id == group_id;
bool from_mentions = d->notification_info->mention_notification_group_.group_id_ == group_id;
auto &group_info = get_notification_group_info(d, from_mentions);
MessageNotificationGroup result;
VLOG(notifications) << "Found " << (from_mentions ? "Mentions " : "Messages ") << group_info.group_id << '/'
VLOG(notifications) << "Found " << (from_mentions ? "Mentions " : "Messages ") << group_info.group_id_ << '/'
<< d->dialog_id << " by " << group_id << " with " << d->unread_mention_count
<< " unread mentions, " << d->unread_reaction_count << " unread reactions, pinned "
<< d->notification_info->pinned_message_notification_message_id_ << ", new secret chat "
@ -29140,12 +29142,12 @@ MessagesManager::MessageNotificationGroup MessagesManager::get_message_notificat
last_notification_date = result.notifications[0].date;
last_notification_id = result.notifications[0].notification_id;
}
if (last_notification_date != group_info.last_notification_date ||
last_notification_id != group_info.last_notification_id) {
LOG(ERROR) << "Fix last notification date in " << d->dialog_id << " from " << group_info.last_notification_date
if (last_notification_date != group_info.last_notification_date_ ||
last_notification_id != group_info.last_notification_id_) {
LOG(ERROR) << "Fix last notification date in " << d->dialog_id << " from " << group_info.last_notification_date_
<< " to " << last_notification_date << " and last notification identifier from "
<< group_info.last_notification_id << " to " << last_notification_id << " in " << group_id << " of type "
<< result.type;
<< group_info.last_notification_id_ << " to " << last_notification_id << " in " << group_id
<< " of type " << result.type;
set_dialog_last_notification(d->dialog_id, group_info, last_notification_date, last_notification_id,
"get_message_notification_group_force");
}
@ -29201,14 +29203,14 @@ bool MessagesManager::is_message_notification_active(const Dialog *d, const Mess
}
if (is_from_mention_notification_group(m)) {
return m->notification_id.get() >
d->notification_info->mention_notification_group_.max_removed_notification_id.get() &&
m->message_id > d->notification_info->mention_notification_group_.max_removed_message_id &&
d->notification_info->mention_notification_group_.max_removed_notification_id_.get() &&
m->message_id > d->notification_info->mention_notification_group_.max_removed_message_id_ &&
(m->contains_unread_mention ||
m->message_id == d->notification_info->pinned_message_notification_message_id_);
} else {
return m->notification_id.get() >
d->notification_info->message_notification_group_.max_removed_notification_id.get() &&
m->message_id > d->notification_info->message_notification_group_.max_removed_message_id &&
d->notification_info->message_notification_group_.max_removed_notification_id_.get() &&
m->message_id > d->notification_info->message_notification_group_.max_removed_message_id_ &&
m->message_id > d->last_read_inbox_message_id;
}
}
@ -29227,8 +29229,8 @@ void MessagesManager::try_add_pinned_message_notification(Dialog *d, vector<Noti
auto m = get_message_force(d, message_id, "try_add_pinned_message_notification");
if (m != nullptr &&
m->notification_id.get() > d->notification_info->mention_notification_group_.max_removed_notification_id.get() &&
m->message_id > d->notification_info->mention_notification_group_.max_removed_message_id &&
m->notification_id.get() > d->notification_info->mention_notification_group_.max_removed_notification_id_.get() &&
m->message_id > d->notification_info->mention_notification_group_.max_removed_message_id_ &&
m->message_id > d->last_read_inbox_message_id && !is_dialog_pinned_message_notifications_disabled(d)) {
if (m->notification_id.get() < max_notification_id.get()) {
VLOG(notifications) << "Add " << m->notification_id << " about pinned " << message_id << " in " << d->dialog_id;
@ -29280,7 +29282,7 @@ vector<Notification> MessagesManager::get_message_notifications_from_database_fo
bool is_found = false;
VLOG(notifications) << "Loaded " << messages.size() << (from_mentions ? " mention" : "")
<< " messages with notifications from database in " << group_info.group_id << '/'
<< " messages with notifications from database in " << group_info.group_id_ << '/'
<< d->dialog_id;
for (auto &message : messages) {
auto m = on_get_message_from_database(d, message, false, "get_message_notifications_from_database_force");
@ -29321,8 +29323,8 @@ vector<Notification> MessagesManager::get_message_notifications_from_database_fo
is_found = true;
}
if (notification_id.get() <= group_info.max_removed_notification_id.get() ||
m->message_id <= group_info.max_removed_message_id ||
if (notification_id.get() <= group_info.max_removed_notification_id_.get() ||
m->message_id <= group_info.max_removed_message_id_ ||
(!from_mentions && m->message_id <= d->last_read_inbox_message_id)) {
// if message still has notification_id, but it was removed via max_removed_notification_id,
// or max_removed_message_id, or last_read_inbox_message_id,
@ -29415,8 +29417,8 @@ vector<NotificationGroupKey> MessagesManager::get_message_notification_group_key
CHECK(group_key.dialog_id.is_valid());
const Dialog *d = get_dialog_force(group_key.dialog_id, "get_message_notification_group_keys_from_database");
if (d == nullptr || d->notification_info == nullptr ||
(d->notification_info->message_notification_group_.group_id != group_key.group_id &&
d->notification_info->mention_notification_group_.group_id != group_key.group_id)) {
(d->notification_info->message_notification_group_.group_id_ != group_key.group_id &&
d->notification_info->mention_notification_group_.group_id_ != group_key.group_id)) {
continue;
}
@ -29448,14 +29450,14 @@ void MessagesManager::get_message_notifications_from_database(DialogId dialog_id
auto d = get_dialog(dialog_id);
CHECK(d != nullptr);
if (d->notification_info == nullptr || (d->notification_info->message_notification_group_.group_id != group_id &&
d->notification_info->mention_notification_group_.group_id != group_id)) {
if (d->notification_info == nullptr || (d->notification_info->message_notification_group_.group_id_ != group_id &&
d->notification_info->mention_notification_group_.group_id_ != group_id)) {
return promise.set_value(vector<Notification>());
}
VLOG(notifications) << "Get " << limit << " message notifications from database in " << group_id << " from "
<< dialog_id << " from " << from_notification_id << "/" << from_message_id;
bool from_mentions = d->notification_info->mention_notification_group_.group_id == group_id;
bool from_mentions = d->notification_info->mention_notification_group_.group_id_ == group_id;
if (d->notification_info->new_secret_chat_notification_id_.is_valid()) {
CHECK(dialog_id.get_type() == DialogType::SecretChat);
vector<Notification> notifications;
@ -29484,8 +29486,8 @@ void MessagesManager::do_get_message_notifications_from_database(Dialog *d, bool
CHECK(!from_message_id.is_scheduled());
auto &group_info = get_notification_group_info(d, from_mentions);
if (from_notification_id.get() <= group_info.max_removed_notification_id.get() ||
from_message_id <= group_info.max_removed_message_id ||
if (from_notification_id.get() <= group_info.max_removed_notification_id_.get() ||
from_message_id <= group_info.max_removed_message_id_ ||
(!from_mentions && from_message_id <= d->last_read_inbox_message_id)) {
return promise.set_value(vector<Notification>());
}
@ -29500,11 +29502,11 @@ void MessagesManager::do_get_message_notifications_from_database(Dialog *d, bool
auto *db = G()->td_db()->get_message_db_async();
if (!from_mentions) {
VLOG(notifications) << "Trying to load " << limit << " messages with notifications in " << group_info.group_id
VLOG(notifications) << "Trying to load " << limit << " messages with notifications in " << group_info.group_id_
<< '/' << dialog_id << " from " << from_notification_id;
return db->get_messages_from_notification_id(d->dialog_id, from_notification_id, limit, std::move(new_promise));
} else {
VLOG(notifications) << "Trying to load " << limit << " messages with unread mentions in " << group_info.group_id
VLOG(notifications) << "Trying to load " << limit << " messages with unread mentions in " << group_info.group_id_
<< '/' << dialog_id << " from " << from_message_id;
// ignore first_db_message_id, notifications can be nonconsecutive
@ -29532,7 +29534,7 @@ void MessagesManager::on_get_message_notifications_from_database(DialogId dialog
CHECK(d != nullptr);
auto &group_info = get_notification_group_info(d, from_mentions);
if (!group_info.group_id.is_valid()) {
if (!group_info.group_id_.is_valid()) {
return promise.set_error(Status::Error("Notification group was deleted"));
}
@ -29541,7 +29543,7 @@ void MessagesManager::on_get_message_notifications_from_database(DialogId dialog
res.reserve(messages.size());
NotificationId from_notification_id;
MessageId from_message_id;
VLOG(notifications) << "Loaded " << messages.size() << " messages with notifications in " << group_info.group_id
VLOG(notifications) << "Loaded " << messages.size() << " messages with notifications in " << group_info.group_id_
<< '/' << dialog_id << " from database";
for (auto &message : messages) {
auto m = on_get_message_from_database(d, message, false, "on_get_message_notifications_from_database");
@ -29579,8 +29581,8 @@ void MessagesManager::on_get_message_notifications_from_database(DialogId dialog
from_message_id = m->message_id;
}
if (notification_id.get() <= group_info.max_removed_notification_id.get() ||
m->message_id <= group_info.max_removed_message_id ||
if (notification_id.get() <= group_info.max_removed_notification_id_.get() ||
m->message_id <= group_info.max_removed_message_id_ ||
(!from_mentions && m->message_id <= d->last_read_inbox_message_id)) {
// if message still has notification_id, but it was removed via max_removed_notification_id,
// or max_removed_message_id, or last_read_inbox_message_id,
@ -29640,8 +29642,8 @@ void MessagesManager::remove_message_notification(DialogId dialog_id, Notificati
LOG(ERROR) << "Can't find " << dialog_id;
return;
}
if (d->notification_info == nullptr || (d->notification_info->message_notification_group_.group_id != group_id &&
d->notification_info->mention_notification_group_.group_id != group_id)) {
if (d->notification_info == nullptr || (d->notification_info->message_notification_group_.group_id_ != group_id &&
d->notification_info->mention_notification_group_.group_id_ != group_id)) {
LOG(ERROR) << "There is no " << group_id << " in " << dialog_id;
return;
}
@ -29649,7 +29651,7 @@ void MessagesManager::remove_message_notification(DialogId dialog_id, Notificati
return; // there can be no notification with this ID
}
bool from_mentions = d->notification_info->mention_notification_group_.group_id == group_id;
bool from_mentions = d->notification_info->mention_notification_group_.group_id_ == group_id;
if (d->notification_info->new_secret_chat_notification_id_.is_valid()) {
if (!from_mentions && d->notification_info->new_secret_chat_notification_id_ == notification_id) {
return remove_new_secret_chat_notification(d, false);
@ -29700,10 +29702,10 @@ void MessagesManager::remove_message_notifications_by_message_ids(DialogId dialo
LOG(INFO) << "Can't delete " << message_id << " because it is not found";
// call synchronously to remove them before ProcessPush returns
td_->notification_manager_->remove_temporary_notification_by_message_id(
d->notification_info->message_notification_group_.group_id, message_id, true,
d->notification_info->message_notification_group_.group_id_, message_id, true,
"remove_message_notifications_by_message_ids");
td_->notification_manager_->remove_temporary_notification_by_message_id(
d->notification_info->mention_notification_group_.group_id, message_id, true,
d->notification_info->mention_notification_group_.group_id_, message_id, true,
"remove_message_notifications_by_message_ids");
continue;
}
@ -29741,8 +29743,8 @@ void MessagesManager::remove_message_notifications(DialogId dialog_id, Notificat
LOG(ERROR) << "Can't find " << dialog_id;
return;
}
if (d->notification_info == nullptr || (d->notification_info->message_notification_group_.group_id != group_id &&
d->notification_info->mention_notification_group_.group_id != group_id)) {
if (d->notification_info == nullptr || (d->notification_info->message_notification_group_.group_id_ != group_id &&
d->notification_info->mention_notification_group_.group_id_ != group_id)) {
LOG(ERROR) << "There is no " << group_id << " in " << dialog_id;
return;
}
@ -29751,7 +29753,7 @@ void MessagesManager::remove_message_notifications(DialogId dialog_id, Notificat
}
CHECK(!max_message_id.is_scheduled());
bool from_mentions = d->notification_info->mention_notification_group_.group_id == group_id;
bool from_mentions = d->notification_info->mention_notification_group_.group_id_ == group_id;
if (d->notification_info->new_secret_chat_notification_id_.is_valid()) {
if (!from_mentions && d->notification_info->new_secret_chat_notification_id_.get() <= max_notification_id.get()) {
return remove_new_secret_chat_notification(d, false);
@ -29759,22 +29761,22 @@ void MessagesManager::remove_message_notifications(DialogId dialog_id, Notificat
return;
}
auto &group_info = get_notification_group_info(d, from_mentions);
if (max_notification_id.get() <= group_info.max_removed_notification_id.get()) {
if (max_notification_id.get() <= group_info.max_removed_notification_id_.get()) {
return;
}
if (max_message_id > group_info.max_removed_message_id) {
VLOG(notifications) << "Set max_removed_message_id in " << group_info.group_id << '/' << dialog_id << " to "
if (max_message_id > group_info.max_removed_message_id_) {
VLOG(notifications) << "Set max_removed_message_id in " << group_info.group_id_ << '/' << dialog_id << " to "
<< max_message_id;
group_info.max_removed_message_id = max_message_id.get_prev_server_message_id();
group_info.max_removed_message_id_ = max_message_id.get_prev_server_message_id();
}
VLOG(notifications) << "Set max_removed_notification_id in " << group_info.group_id << '/' << dialog_id << " to "
VLOG(notifications) << "Set max_removed_notification_id in " << group_info.group_id_ << '/' << dialog_id << " to "
<< max_notification_id;
group_info.max_removed_notification_id = max_notification_id;
group_info.max_removed_notification_id_ = max_notification_id;
on_dialog_updated(dialog_id, "remove_message_notifications");
if (group_info.last_notification_id.is_valid() &&
max_notification_id.get() >= group_info.last_notification_id.get()) {
if (group_info.last_notification_id_.is_valid() &&
max_notification_id.get() >= group_info.last_notification_id_.get()) {
bool is_changed =
set_dialog_last_notification(dialog_id, group_info, 0, NotificationId(), "remove_message_notifications");
CHECK(is_changed);
@ -29805,7 +29807,7 @@ int32 MessagesManager::get_dialog_pending_notification_count(const Dialog *d, bo
void MessagesManager::update_dialog_mention_notification_count(const Dialog *d) {
CHECK(d != nullptr);
if (td_->auth_manager_->is_bot() || d->notification_info == nullptr ||
!d->notification_info->mention_notification_group_.group_id.is_valid()) {
!d->notification_info->mention_notification_group_.group_id_.is_valid()) {
return;
}
auto total_count = get_dialog_pending_notification_count(d, true) -
@ -29816,7 +29818,7 @@ void MessagesManager::update_dialog_mention_notification_count(const Dialog *d)
total_count = 0;
}
send_closure_later(G()->notification_manager(), &NotificationManager::set_notification_total_count,
d->notification_info->mention_notification_group_.group_id, total_count);
d->notification_info->mention_notification_group_.group_id_, total_count);
}
bool MessagesManager::is_message_notification_disabled(const Dialog *d, const Message *m) const {
@ -29915,13 +29917,13 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
CHECK(m->message_id.is_valid());
if (!force && d->notification_info != nullptr) {
if (d->notification_info->message_notification_group_.group_id.is_valid()) {
if (d->notification_info->message_notification_group_.group_id_.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notifications,
d->notification_info->message_notification_group_.group_id, "add_new_message_notification 1");
d->notification_info->message_notification_group_.group_id_, "add_new_message_notification 1");
}
if (d->notification_info->mention_notification_group_.group_id.is_valid()) {
if (d->notification_info->mention_notification_group_.group_id_.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notifications,
d->notification_info->mention_notification_group_.group_id, "add_new_message_notification 2");
d->notification_info->mention_notification_group_.group_id_, "add_new_message_notification 2");
}
}
@ -29936,7 +29938,7 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
from_mentions ? m->contains_unread_mention || is_pinned : m->message_id > d->last_read_inbox_message_id;
if (is_active) {
auto &group_info = get_notification_group_info(d, from_mentions);
if (group_info.max_removed_message_id >= m->message_id) {
if (group_info.max_removed_message_id_ >= m->message_id) {
is_active = false;
}
}
@ -30060,7 +30062,7 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
// protection from accidental notification_id removal in set_dialog_pinned_message_notification
return false;
}
VLOG(notifications) << "Create " << m->notification_id << " with " << m->message_id << " in " << group_info.group_id
VLOG(notifications) << "Create " << m->notification_id << " with " << m->message_id << " in " << group_info.group_id_
<< '/' << d->dialog_id;
int32 min_delay_ms = 0;
if (need_delay_message_content_notification(m->content.get(), td_->contacts_manager_->get_my_id())) {
@ -30120,19 +30122,19 @@ void MessagesManager::flush_pending_new_message_notifications(DialogId dialog_id
}
void MessagesManager::remove_all_dialog_notifications(Dialog *d, bool from_mentions, const char *source) {
// removes up to group_info.last_notification_id
// removes up to group_info.last_notification_id_
CHECK(!td_->auth_manager_->is_bot());
if (d->notification_info == nullptr) {
return;
}
NotificationGroupInfo &group_info = get_notification_group_info(d, from_mentions);
if (group_info.group_id.is_valid() && group_info.last_notification_id.is_valid() &&
group_info.max_removed_notification_id != group_info.last_notification_id) {
VLOG(notifications) << "Set max_removed_notification_id in " << group_info.group_id << '/' << d->dialog_id << " to "
<< group_info.last_notification_id << " from " << source;
group_info.max_removed_notification_id = group_info.last_notification_id;
if (d->notification_info->max_notification_message_id_ > group_info.max_removed_message_id) {
group_info.max_removed_message_id =
if (group_info.group_id_.is_valid() && group_info.last_notification_id_.is_valid() &&
group_info.max_removed_notification_id_ != group_info.last_notification_id_) {
VLOG(notifications) << "Set max_removed_notification_id in " << group_info.group_id_ << '/' << d->dialog_id
<< " to " << group_info.last_notification_id_ << " from " << source;
group_info.max_removed_notification_id_ = group_info.last_notification_id_;
if (d->notification_info->max_notification_message_id_ > group_info.max_removed_message_id_) {
group_info.max_removed_message_id_ =
d->notification_info->max_notification_message_id_.get_prev_server_message_id();
}
if (!d->notification_info->pending_new_message_notifications_.empty()) {
@ -30143,7 +30145,7 @@ void MessagesManager::remove_all_dialog_notifications(Dialog *d, bool from_menti
}
// remove_message_notifications will be called by NotificationManager
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification_group,
group_info.group_id, group_info.last_notification_id, MessageId(), 0, true, Promise<Unit>());
group_info.group_id_, group_info.last_notification_id_, MessageId(), 0, true, Promise<Unit>());
if (d->notification_info->new_secret_chat_notification_id_.is_valid() &&
&group_info == &d->notification_info->message_notification_group_) {
remove_new_secret_chat_notification(d, false);
@ -30163,11 +30165,11 @@ void MessagesManager::remove_message_dialog_notifications(Dialog *d, MessageId m
return;
}
NotificationGroupInfo &group_info = get_notification_group_info(d, from_mentions);
if (!group_info.group_id.is_valid()) {
if (!group_info.group_id_.is_valid()) {
return;
}
VLOG(notifications) << "Remove message dialog notifications in " << group_info.group_id << '/' << d->dialog_id
VLOG(notifications) << "Remove message dialog notifications in " << group_info.group_id_ << '/' << d->dialog_id
<< " up to " << max_message_id << " from " << source;
if (!d->notification_info->pending_new_message_notifications_.empty()) {
@ -30192,7 +30194,7 @@ void MessagesManager::remove_message_dialog_notifications(Dialog *d, MessageId m
LOG(FATAL) << "TODO support notification deletion up to " << max_message_id << " if it would be ever needed";
}
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification_group, group_info.group_id,
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification_group, group_info.group_id_,
NotificationId(), max_notification_message_id, 0, true, Promise<Unit>());
}
@ -34901,13 +34903,13 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
auto notification_id = message->notification_id;
VLOG(notifications) << "Remove mention " << notification_id << " in " << message_id << " in " << dialog_id;
message->notification_id = NotificationId();
if (d->notification_info->mention_notification_group_.last_notification_id == notification_id) {
if (d->notification_info->mention_notification_group_.last_notification_id_ == notification_id) {
// last notification is deleted, need to find new last notification
fix_dialog_last_notification_id(d, true, message_id);
}
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification,
d->notification_info->mention_notification_group_.group_id, notification_id, false, false,
d->notification_info->mention_notification_group_.group_id_, notification_id, false, false,
Promise<Unit>(), "remove disabled mention notification");
on_message_changed(d, message.get(), false, "remove_mention_notification");
@ -35277,8 +35279,8 @@ void MessagesManager::on_message_notification_changed(Dialog *d, const Message *
CHECK(m != nullptr);
if (m->notification_id.is_valid() && is_message_notification_active(d, m)) {
auto &group_info = get_notification_group_info(d, m);
if (group_info.group_id.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::edit_notification, group_info.group_id,
if (group_info.group_id_.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::edit_notification, group_info.group_id_,
m->notification_id,
create_new_message_notification(
m->message_id, is_message_preview_enabled(d, m, is_from_mention_notification_group(m))));
@ -35286,7 +35288,7 @@ void MessagesManager::on_message_notification_changed(Dialog *d, const Message *
}
if (m->is_pinned && d->notification_info != nullptr &&
d->notification_info->pinned_message_notification_message_id_.is_valid() &&
d->notification_info->mention_notification_group_.group_id.is_valid()) {
d->notification_info->mention_notification_group_.group_id_.is_valid()) {
auto pinned_message =
get_message_force(d, d->notification_info->pinned_message_notification_message_id_, "after update_message");
if (pinned_message != nullptr && pinned_message->notification_id.is_valid() &&
@ -35294,7 +35296,7 @@ void MessagesManager::on_message_notification_changed(Dialog *d, const Message *
get_message_content_pinned_message_id(pinned_message->content.get()) == m->message_id) {
send_closure_later(
G()->notification_manager(), &NotificationManager::edit_notification,
d->notification_info->mention_notification_group_.group_id, pinned_message->notification_id,
d->notification_info->mention_notification_group_.group_id_, pinned_message->notification_id,
create_new_message_notification(pinned_message->message_id, is_message_preview_enabled(d, m, true)));
}
}
@ -35551,22 +35553,22 @@ void MessagesManager::delete_message_from_database(Dialog *d, MessageId message_
auto from_mentions = is_from_mention_notification_group(m);
auto &group_info = get_notification_group_info(d, from_mentions);
if (group_info.group_id.is_valid()) {
if (group_info.last_notification_id == m->notification_id) {
if (group_info.group_id_.is_valid()) {
if (group_info.last_notification_id_ == m->notification_id) {
// last notification is deleted, need to find new last notification
fix_dialog_last_notification_id(d, from_mentions, m->message_id);
}
if (is_message_notification_active(d, m)) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification, group_info.group_id,
send_closure_later(G()->notification_manager(), &NotificationManager::remove_notification, group_info.group_id_,
m->notification_id, true, false, Promise<Unit>(), "delete_message_from_database");
}
}
} else if (!message_id.is_scheduled() && message_id > d->last_new_message_id && d->notification_info != nullptr) {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->notification_info->message_notification_group_.group_id, message_id, false,
d->notification_info->message_notification_group_.group_id_, message_id, false,
"delete_message_from_database");
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->notification_info->mention_notification_group_.group_id, message_id, false,
d->notification_info->mention_notification_group_.group_id_, message_id, false,
"delete_message_from_database");
}
@ -36578,12 +36580,12 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr<Dialog> &&di
}
if (d->notification_info != nullptr) {
if (d->notification_info->message_notification_group_.group_id.is_valid()) {
notification_group_id_to_dialog_id_.emplace(d->notification_info->message_notification_group_.group_id,
if (d->notification_info->message_notification_group_.group_id_.is_valid()) {
notification_group_id_to_dialog_id_.emplace(d->notification_info->message_notification_group_.group_id_,
dialog_id);
}
if (d->notification_info->mention_notification_group_.group_id.is_valid()) {
notification_group_id_to_dialog_id_.emplace(d->notification_info->mention_notification_group_.group_id,
if (d->notification_info->mention_notification_group_.group_id_.is_valid()) {
notification_group_id_to_dialog_id_.emplace(d->notification_info->mention_notification_group_.group_id_,
dialog_id);
}
}
@ -36725,18 +36727,18 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
}
if (d->notification_info != nullptr && d->notification_info->pinned_message_notification_message_id_.is_valid()) {
auto pinned_message_id = d->notification_info->pinned_message_notification_message_id_;
if (!d->notification_info->mention_notification_group_.group_id.is_valid()) {
if (!d->notification_info->mention_notification_group_.group_id_.is_valid()) {
LOG(ERROR) << "Have pinned message notification in " << pinned_message_id << " in " << dialog_id
<< ", but there is no mention notification group";
d->notification_info->pinned_message_notification_message_id_ = MessageId();
on_dialog_updated(dialog_id, "fix pinned message notification");
} else if (is_dialog_pinned_message_notifications_disabled(d) ||
pinned_message_id <= d->last_read_inbox_message_id ||
pinned_message_id <= d->notification_info->mention_notification_group_.max_removed_message_id) {
pinned_message_id <= d->notification_info->mention_notification_group_.max_removed_message_id_) {
VLOG(notifications) << "Remove disabled pinned message notification in " << pinned_message_id << " in "
<< dialog_id;
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->notification_info->mention_notification_group_.group_id, pinned_message_id, true,
d->notification_info->mention_notification_group_.group_id_, pinned_message_id, true,
"fix pinned message notification");
d->notification_info->pinned_message_notification_message_id_ = MessageId();
on_dialog_updated(dialog_id, "fix pinned message notification 2");
@ -36744,8 +36746,8 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
}
if (d->notification_info != nullptr && d->notification_info->new_secret_chat_notification_id_.is_valid()) {
auto &group_info = d->notification_info->message_notification_group_;
if (d->notification_info->new_secret_chat_notification_id_.get() <= group_info.max_removed_notification_id.get() ||
(group_info.last_notification_date == 0 && group_info.max_removed_notification_id.get() == 0)) {
if (d->notification_info->new_secret_chat_notification_id_.get() <= group_info.max_removed_notification_id_.get() ||
(group_info.last_notification_date_ == 0 && group_info.max_removed_notification_id_.get() == 0)) {
VLOG(notifications) << "Fix removing new secret chat " << d->notification_info->new_secret_chat_notification_id_
<< " in " << dialog_id;
d->notification_info->new_secret_chat_notification_id_ = NotificationId();
@ -38194,13 +38196,13 @@ void MessagesManager::do_get_channel_difference(DialogId dialog_id, int32 pts, b
// can be called multiple times before after_get_channel_difference
const Dialog *d = get_dialog(dialog_id);
if (d != nullptr && d->notification_info != nullptr) {
if (d->notification_info->message_notification_group_.group_id.is_valid()) {
if (d->notification_info->message_notification_group_.group_id_.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::before_get_chat_difference,
d->notification_info->message_notification_group_.group_id);
d->notification_info->message_notification_group_.group_id_);
}
if (d->notification_info->mention_notification_group_.group_id.is_valid()) {
if (d->notification_info->mention_notification_group_.group_id_.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::before_get_chat_difference,
d->notification_info->mention_notification_group_.group_id);
d->notification_info->mention_notification_group_.group_id_);
}
}
@ -38851,13 +38853,13 @@ void MessagesManager::after_get_channel_difference(DialogId dialog_id, bool succ
d->is_channel_difference_finished = true;
if (d->notification_info != nullptr) {
if (d->notification_info->message_notification_group_.group_id.is_valid()) {
if (d->notification_info->message_notification_group_.group_id_.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::after_get_chat_difference,
d->notification_info->message_notification_group_.group_id);
d->notification_info->message_notification_group_.group_id_);
}
if (d->notification_info->mention_notification_group_.group_id.is_valid()) {
if (d->notification_info->mention_notification_group_.group_id_.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::after_get_chat_difference,
d->notification_info->mention_notification_group_.group_id);
d->notification_info->mention_notification_group_.group_id_);
}
}
} else {

View File

@ -11,49 +11,49 @@
namespace td {
void NotificationGroupInfo::try_reuse() {
CHECK(group_id.is_valid());
CHECK(last_notification_date == 0);
CHECK(group_id_.is_valid());
CHECK(last_notification_date_ == 0);
if (!try_reuse_) {
try_reuse_ = true;
is_changed = true;
is_changed_ = true;
}
}
void NotificationGroupInfo::add_group_key_if_changed(vector<NotificationGroupKey> &group_keys, DialogId dialog_id) {
if (!is_changed) {
if (!is_changed_) {
return;
}
is_changed = false;
is_changed_ = false;
group_keys.emplace_back(group_id, try_reuse_ ? DialogId() : dialog_id, last_notification_date);
group_keys.emplace_back(group_id_, try_reuse_ ? DialogId() : dialog_id, last_notification_date_);
}
NotificationGroupId NotificationGroupInfo::get_reused_group_id() {
if (!try_reuse_) {
return {};
}
if (is_changed) {
LOG(ERROR) << "Failed to reuse changed " << group_id;
if (is_changed_) {
LOG(ERROR) << "Failed to reuse changed " << group_id_;
return {};
}
try_reuse_ = false;
if (!group_id.is_valid()) {
LOG(ERROR) << "Failed to reuse invalid " << group_id;
if (!group_id_.is_valid()) {
LOG(ERROR) << "Failed to reuse invalid " << group_id_;
return {};
}
CHECK(last_notification_id == NotificationId());
CHECK(last_notification_date == 0);
auto result = group_id;
group_id = NotificationGroupId();
max_removed_notification_id = NotificationId();
max_removed_message_id = MessageId();
CHECK(last_notification_id_ == NotificationId());
CHECK(last_notification_date_ == 0);
auto result = group_id_;
group_id_ = NotificationGroupId();
max_removed_notification_id_ = NotificationId();
max_removed_message_id_ = MessageId();
return result;
}
StringBuilder &operator<<(StringBuilder &string_builder, const NotificationGroupInfo &group_info) {
return string_builder << group_info.group_id << " with last " << group_info.last_notification_id << " sent at "
<< group_info.last_notification_date << ", max removed "
<< group_info.max_removed_notification_id << '/' << group_info.max_removed_message_id;
return string_builder << group_info.group_id_ << " with last " << group_info.last_notification_id_ << " sent at "
<< group_info.last_notification_date_ << ", max removed "
<< group_info.max_removed_notification_id_ << '/' << group_info.max_removed_message_id_;
}
} // namespace td

View File

@ -18,15 +18,15 @@ class NotificationGroupInfo {
bool try_reuse_ = false; // true, if the group needs to be deleted from database and tried to be reused
public:
NotificationGroupId group_id;
int32 last_notification_date = 0; // date of last notification in the group
NotificationId last_notification_id; // identifier of last notification in the group
NotificationId max_removed_notification_id; // notification identifier, up to which all notifications are removed
MessageId max_removed_message_id; // message identifier, up to which all notifications are removed
bool is_changed = false; // true, if the group needs to be saved to database
NotificationGroupId group_id_;
int32 last_notification_date_ = 0; // date of last notification in the group
NotificationId last_notification_id_; // identifier of last notification in the group
NotificationId max_removed_notification_id_; // notification identifier, up to which all notifications are removed
MessageId max_removed_message_id_; // message identifier, up to which all notifications are removed
bool is_changed_ = false; // true, if the group needs to be saved to database
bool is_active() const {
return group_id.is_valid() && !try_reuse_;
return group_id_.is_valid() && !try_reuse_;
}
void try_reuse();

View File

@ -16,22 +16,22 @@ namespace td {
template <class StorerT>
void NotificationGroupInfo::store(StorerT &storer) const {
using td::store;
store(group_id, storer);
store(last_notification_date, storer);
store(last_notification_id, storer);
store(max_removed_notification_id, storer);
store(max_removed_message_id, storer);
store(group_id_, storer);
store(last_notification_date_, storer);
store(last_notification_id_, storer);
store(max_removed_notification_id_, storer);
store(max_removed_message_id_, storer);
}
template <class ParserT>
void NotificationGroupInfo::parse(ParserT &parser) {
using td::parse;
parse(group_id, parser);
parse(last_notification_date, parser);
parse(last_notification_id, parser);
parse(max_removed_notification_id, parser);
parse(group_id_, parser);
parse(last_notification_date_, parser);
parse(last_notification_id_, parser);
parse(max_removed_notification_id_, parser);
if (parser.version() >= static_cast<int32>(Version::AddNotificationGroupInfoMaxRemovedMessageId)) {
parse(max_removed_message_id, parser);
parse(max_removed_message_id_, parser);
}
}