From 801137dcf37ae48e8646fa089afb6df96d1be425 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 26 Feb 2020 00:28:03 +0300 Subject: [PATCH] Repair scheduled messages after receiving opposite server flag. GitOrigin-RevId: 5cead2b4fd6c52835b5dc775efaa9c855d72feb3 --- td/telegram/MessagesManager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index f2cb4c7d1..b2b275790 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17433,6 +17433,7 @@ void MessagesManager::load_messages(DialogId dialog_id, MessageId from_message_i } vector MessagesManager::get_dialog_scheduled_messages(DialogId dialog_id, Promise &&promise) { + LOG(INFO) << "Get scheduled messages in " << dialog_id; if (G()->close_flag()) { promise.set_error(Status::Error(500, "Request aborted")); return {}; @@ -22817,6 +22818,9 @@ void MessagesManager::send_update_chat_has_scheduled_messages(Dialog *d) { set_dialog_has_scheduled_database_messages_impl(d, false); } + LOG(INFO) << "Have sheduled messages on server = " << d->has_scheduled_server_messages + << ", in database = " << d->has_scheduled_database_messages + << " and in memory = " << (d->scheduled_messages != nullptr); bool has_scheduled_messages = d->has_scheduled_server_messages || d->has_scheduled_database_messages || d->scheduled_messages != nullptr; if (has_scheduled_messages == d->last_sent_has_scheduled_messages) { @@ -23656,6 +23660,7 @@ void MessagesManager::repair_dialog_scheduled_messages(DialogId dialog_id) { } // TODO create logevent + LOG(INFO) << "Repair sheduled messages in " << dialog_id; get_dialog_scheduled_messages(dialog_id, PromiseCreator::lambda([actor_id = actor_id(this), dialog_id](Unit) { send_closure(G()->messages_manager(), &MessagesManager::get_dialog_scheduled_messages, dialog_id, Promise()); @@ -23681,6 +23686,9 @@ void MessagesManager::on_update_dialog_has_scheduled_server_messages(DialogId di LOG(INFO) << "Receive has_scheduled_server_messages = " << has_scheduled_server_messages << " in " << dialog_id; if (d->has_scheduled_server_messages != has_scheduled_server_messages) { set_dialog_has_scheduled_server_messages(d, has_scheduled_server_messages); + } else if (has_scheduled_server_messages != + (d->has_scheduled_database_messages || d->scheduled_messages != nullptr)) { + repair_dialog_scheduled_messages(d->dialog_id); } }