Improve field name.

This commit is contained in:
levlam 2023-08-27 02:48:18 +03:00
parent 4b3750cefe
commit 04b376782c
2 changed files with 29 additions and 27 deletions

View File

@ -5229,9 +5229,9 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
notification_info != nullptr && notification_info->pinned_message_notification_message_id_.is_valid();
bool has_last_pinned_message_id = last_pinned_message_id.is_valid();
bool has_flags2 = true;
bool has_max_notification_message_id = notification_info != nullptr &&
notification_info->max_notification_message_id_.is_valid() &&
notification_info->max_notification_message_id_ > last_new_message_id;
bool has_max_push_notification_message_id =
notification_info != nullptr && notification_info->max_push_notification_message_id_.is_valid() &&
notification_info->max_push_notification_message_id_ > last_new_message_id;
bool has_folder_id = folder_id != FolderId();
bool has_pending_read_channel_inbox = pending_read_channel_inbox_pts != 0;
bool has_last_yet_unsent_message = last_message_id.is_valid() && last_message_id.is_yet_unsent();
@ -5287,7 +5287,7 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
if (has_flags2) {
BEGIN_STORE_FLAGS();
STORE_FLAG(has_max_notification_message_id);
STORE_FLAG(has_max_push_notification_message_id);
STORE_FLAG(has_folder_id);
STORE_FLAG(is_folder_id_inited);
STORE_FLAG(has_pending_read_channel_inbox);
@ -5409,8 +5409,8 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
if (has_last_pinned_message_id) {
store(last_pinned_message_id, storer);
}
if (has_max_notification_message_id) {
store(notification_info->max_notification_message_id_, storer);
if (has_max_push_notification_message_id) {
store(notification_info->max_push_notification_message_id_, storer);
}
if (has_folder_id) {
store(folder_id, storer);
@ -5483,7 +5483,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
bool has_pinned_message_notification;
bool has_last_pinned_message_id;
bool has_flags2;
bool has_max_notification_message_id = false;
bool has_max_push_notification_message_id = false;
bool has_folder_id = false;
bool has_pending_read_channel_inbox = false;
bool has_active_group_call_id = false;
@ -5545,7 +5545,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
if (has_flags2) {
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_max_notification_message_id);
PARSE_FLAG(has_max_push_notification_message_id);
PARSE_FLAG(has_folder_id);
PARSE_FLAG(is_folder_id_inited);
PARSE_FLAG(has_pending_read_channel_inbox);
@ -5723,8 +5723,8 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
if (has_last_pinned_message_id) {
parse(last_pinned_message_id, parser);
}
if (has_max_notification_message_id) {
parse(add_dialog_notification_info(this)->max_notification_message_id_, parser);
if (has_max_push_notification_message_id) {
parse(add_dialog_notification_info(this)->max_push_notification_message_id_, parser);
}
if (has_folder_id) {
parse(folder_id, parser);
@ -12520,10 +12520,11 @@ void MessagesManager::read_history_inbox(Dialog *d, MessageId max_message_id, in
}
}
LOG_IF(INFO,
d->last_new_message_id.is_valid() && max_message_id > d->last_new_message_id &&
(d->notification_info != nullptr && max_message_id > d->notification_info->max_notification_message_id_) &&
max_message_id.is_server() && dialog_id.get_type() != DialogType::Channel && !running_get_difference_)
LOG_IF(INFO, d->last_new_message_id.is_valid() && max_message_id > d->last_new_message_id &&
(d->notification_info != nullptr &&
max_message_id > d->notification_info->max_push_notification_message_id_) &&
max_message_id.is_server() && dialog_id.get_type() != DialogType::Channel &&
!running_get_difference_)
<< "Receive read inbox update up to unknown " << max_message_id << " in " << dialog_id << " from " << source
<< ". Last new is " << d->last_new_message_id << ", unread_count = " << unread_count
<< ". Possible only for deleted incoming message";
@ -20167,7 +20168,7 @@ Status MessagesManager::view_messages(DialogId dialog_id, vector<MessageId> mess
}
}
} else if (!message_id.is_yet_unsent() && message_id > max_message_id) {
if ((d->notification_info != nullptr && message_id <= d->notification_info->max_notification_message_id_) ||
if ((d->notification_info != nullptr && message_id <= d->notification_info->max_push_notification_message_id_) ||
message_id <= d->last_new_message_id || message_id <= max_thread_message_id) {
max_message_id = message_id;
}
@ -24606,7 +24607,7 @@ MessageInputReplyTo MessagesManager::get_message_input_reply_to(Dialog *d, Messa
(m->message_id.is_local() && d->dialog_id.get_type() != DialogType::SecretChat)) {
if (message_id.is_server() && d->dialog_id.get_type() != DialogType::SecretChat &&
message_id > d->last_new_message_id &&
(d->notification_info != nullptr && message_id <= d->notification_info->max_notification_message_id_)) {
(d->notification_info != nullptr && message_id <= d->notification_info->max_push_notification_message_id_)) {
// allow to reply yet unreceived server message
return {message_id, StoryFullId()};
}
@ -29002,17 +29003,17 @@ Result<MessagesManager::MessagePushNotificationInfo> MessagesManager::get_messag
bool is_new_pinned =
is_pinned && message_id.is_valid() &&
(d->notification_info == nullptr || message_id > d->notification_info->max_notification_message_id_);
(d->notification_info == nullptr || message_id > d->notification_info->max_push_notification_message_id_);
CHECK(!message_id.is_scheduled());
if (message_id.is_valid()) {
if (message_id <= d->last_new_message_id) {
return Status::Error("Ignore notification about known message");
}
if (!is_from_binlog && d->notification_info != nullptr) {
if (message_id == d->notification_info->max_notification_message_id_) {
if (message_id == d->notification_info->max_push_notification_message_id_) {
return Status::Error("Ignore previously added message push notification");
}
if (message_id < d->notification_info->max_notification_message_id_) {
if (message_id < d->notification_info->max_push_notification_message_id_) {
return Status::Error("Ignore out of order message push notification");
}
}
@ -29079,13 +29080,13 @@ Result<MessagesManager::MessagePushNotificationInfo> MessagesManager::get_messag
if (message_id.is_valid()) {
auto notification_info = add_dialog_notification_info(d);
if (message_id > notification_info->max_notification_message_id_) {
if (message_id > notification_info->max_push_notification_message_id_) {
if (is_new_pinned) {
set_dialog_pinned_message_notification(d, contains_mention ? message_id : MessageId(),
"get_message_push_notification_info");
}
notification_info->max_notification_message_id_ = message_id;
on_dialog_updated(dialog_id, "set_max_notification_message_id");
notification_info->max_push_notification_message_id_ = message_id;
on_dialog_updated(dialog_id, "set_max_push_notification_message_id");
}
}
@ -30073,7 +30074,7 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
min_delay_ms = 1000; // 1 second
}
auto ringtone_id = get_dialog_notification_ringtone_id(settings_dialog_id, settings_dialog);
bool is_silent = m->disable_notification || m->message_id <= notification_info->max_notification_message_id_;
bool is_silent = m->disable_notification || m->message_id <= notification_info->max_push_notification_message_id_;
send_closure_later(G()->notification_manager(), &NotificationManager::add_notification, notification_group_id,
from_mentions ? NotificationGroupType::Mentions : NotificationGroupType::Messages, d->dialog_id,
m->date, settings_dialog_id, m->disable_notification, is_silent ? 0 : ringtone_id, min_delay_ms,
@ -30132,8 +30133,8 @@ void MessagesManager::remove_all_dialog_notifications(Dialog *d, bool from_menti
NotificationGroupInfo &group_info = get_notification_group_info(d, from_mentions);
if (group_info.is_valid() && group_info.get_last_notification_id().is_valid()) {
auto last_notification_id = group_info.get_last_notification_id();
group_info.set_max_removed_notification_id(
last_notification_id, d->notification_info->max_notification_message_id_.get_prev_server_message_id(), source);
group_info.set_max_removed_notification_id(last_notification_id,
d->notification_info->max_push_notification_message_id_, source);
on_dialog_updated(d->dialog_id, source);
if (!d->notification_info->pending_new_message_notifications_.empty()) {
@ -36967,7 +36968,8 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
<< " and pinned " << d->notification_info->pinned_message_notification_message_id_;
VLOG(notifications) << "In " << dialog_id << " have last_read_inbox_message_id = " << d->last_read_inbox_message_id
<< ", last_new_message_id = " << d->last_new_message_id
<< ", max_notification_message_id = " << d->notification_info->max_notification_message_id_;
<< ", max_push_notification_message_id = "
<< d->notification_info->max_push_notification_message_id_;
}
LOG_CHECK(d->messages.calc_size() <= 1)

View File

@ -1302,7 +1302,7 @@ class MessagesManager final : public Actor {
NotificationGroupInfo mention_notification_group_;
NotificationId new_secret_chat_notification_id_; // secret chats only
MessageId pinned_message_notification_message_id_;
MessageId max_notification_message_id_;
MessageId max_push_notification_message_id_;
vector<std::pair<DialogId, MessageId>> pending_new_message_notifications_;
vector<std::pair<DialogId, MessageId>> pending_new_mention_notifications_;