From 4344d1235e55fdc13e9cb9bda93d7a2d9f7e2bf9 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 20 May 2024 17:13:15 +0300 Subject: [PATCH] Fix identifier generation for failed to send messages for bots with database. --- td/telegram/MessagesManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index f137d864c..32e7ccbe7 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -29796,7 +29796,11 @@ void MessagesManager::fail_send_message(MessageFullId message_full_id, int32 err if (get_message_force(d, new_message_id, "fail_send_message") != nullptr || is_deleted_message(d, new_message_id) || new_message_id <= d->last_clear_history_message_id) { new_message_id = get_next_local_message_id(d); - } else if (new_message_id > d->last_assigned_message_id) { + while (get_message_force(d, new_message_id, "fail_send_message") != nullptr) { + new_message_id = new_message_id.get_next_message_id(MessageType::Local); + } + } + if (new_message_id > d->last_assigned_message_id) { d->last_assigned_message_id = new_message_id; } } else {