Pass Dialog to read_history_outbox.

This commit is contained in:
levlam 2023-05-13 03:51:27 +03:00
parent 57d3928a50
commit f61b5900dd
2 changed files with 48 additions and 38 deletions

View File

@ -12551,8 +12551,7 @@ void MessagesManager::read_history_inbox(DialogId dialog_id, MessageId max_messa
} }
} }
void MessagesManager::read_history_inbox(Dialog *d, MessageId max_message_id, int32 unread_count, void MessagesManager::read_history_inbox(Dialog *d, MessageId max_message_id, int32 unread_count, const char *source) {
const char *source) {
if (td_->auth_manager_->is_bot()) { if (td_->auth_manager_->is_bot()) {
return; return;
} }
@ -12646,6 +12645,18 @@ void MessagesManager::read_history_outbox(DialogId dialog_id, MessageId max_mess
Dialog *d = get_dialog_force(dialog_id, "read_history_outbox"); Dialog *d = get_dialog_force(dialog_id, "read_history_outbox");
if (d != nullptr) { if (d != nullptr) {
read_history_outbox(d, max_message_id, read_date);
} else {
LOG(INFO) << "Receive read outbox update about unknown " << dialog_id;
}
}
void MessagesManager::read_history_outbox(Dialog *d, MessageId max_message_id, int32 read_date) {
if (td_->auth_manager_->is_bot()) {
return;
}
auto dialog_id = d->dialog_id;
if (!max_message_id.is_valid()) { if (!max_message_id.is_valid()) {
LOG(ERROR) << "Receive read outbox update in " << dialog_id << " with " << max_message_id; LOG(ERROR) << "Receive read outbox update in " << dialog_id << " with " << max_message_id;
return; return;
@ -12680,9 +12691,6 @@ void MessagesManager::read_history_outbox(DialogId dialog_id, MessageId max_mess
} }
set_dialog_last_read_outbox_message_id(d, max_message_id); set_dialog_last_read_outbox_message_id(d, max_message_id);
} else {
LOG(INFO) << "Receive read outbox update about unknown " << dialog_id;
}
} }
bool MessagesManager::need_unread_counter(int64 dialog_order) { bool MessagesManager::need_unread_counter(int64 dialog_order) {
@ -14068,7 +14076,7 @@ void MessagesManager::read_secret_chat_outbox_inner(DialogId dialog_id, int32 up
return; return;
} }
auto max_message_id = (*end)->get_message_id(); auto max_message_id = (*end)->get_message_id();
read_history_outbox(dialog_id, max_message_id, read_date); read_history_outbox(d, max_message_id, read_date);
} }
void MessagesManager::open_secret_message(SecretChatId secret_chat_id, int64 random_id, Promise<Unit> promise) { void MessagesManager::open_secret_message(SecretChatId secret_chat_id, int64 random_id, Promise<Unit> promise) {
@ -28537,7 +28545,7 @@ Result<MessageId> MessagesManager::add_local_message(
if (is_message_auto_read(dialog_id, result->is_outgoing)) { if (is_message_auto_read(dialog_id, result->is_outgoing)) {
if (result->is_outgoing) { if (result->is_outgoing) {
read_history_outbox(dialog_id, message_id); read_history_outbox(d, message_id);
} else { } else {
read_history_inbox(d, message_id, 0, "add_local_message"); read_history_inbox(d, message_id, 0, "add_local_message");
} }

View File

@ -2115,6 +2115,8 @@ class MessagesManager final : public Actor {
bool has_incoming_notification(DialogId dialog_id, const Message *m) const; bool has_incoming_notification(DialogId dialog_id, const Message *m) const;
void read_history_outbox(Dialog *d, MessageId max_message_id, int32 read_date = -1);
void read_history_inbox(Dialog *d, MessageId max_message_id, int32 unread_count, const char *source); void read_history_inbox(Dialog *d, MessageId max_message_id, int32 unread_count, const char *source);
void read_dialog_inbox(Dialog *d, MessageId max_message_id); void read_dialog_inbox(Dialog *d, MessageId max_message_id);