From eecb0476b516840e533b2a65139f9348b118cace Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 10 May 2021 19:36:18 +0300 Subject: [PATCH] Unify error messages for private and secret chats. --- td/telegram/MessagesManager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 750f33ba9..d437738d1 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -28938,14 +28938,13 @@ void MessagesManager::on_send_message_fail(int64 random_id, Status error) { if (td_->auth_manager_->is_bot()) { switch (dialog_id.get_type()) { case DialogType::User: + case DialogType::SecretChat: error_message = "Bot was blocked by the user"; break; case DialogType::Chat: case DialogType::Channel: error_message = "Bot was kicked from the chat"; break; - case DialogType::SecretChat: - break; case DialogType::None: default: UNREACHABLE(); @@ -28953,14 +28952,13 @@ void MessagesManager::on_send_message_fail(int64 random_id, Status error) { } else { switch (dialog_id.get_type()) { case DialogType::User: + case DialogType::SecretChat: error_message = "User was blocked by the other user"; break; case DialogType::Chat: case DialogType::Channel: error_message = "User is not in the chat"; break; - case DialogType::SecretChat: - break; case DialogType::None: default: UNREACHABLE(); @@ -28968,7 +28966,8 @@ void MessagesManager::on_send_message_fail(int64 random_id, Status error) { } // TODO add check to send_message } else if (error.message() == "USER_IS_BOT") { - if (td_->auth_manager_->is_bot() && dialog_id.get_type() == DialogType::User) { + if (td_->auth_manager_->is_bot() && + (dialog_id.get_type() == DialogType::User || dialog_id.get_type() == DialogType::SecretChat)) { error_code = 403; if (td_->contacts_manager_->is_user_bot(dialog_id.get_user_id())) { error_message = "Bot can't send messages to bots"; @@ -28979,7 +28978,8 @@ void MessagesManager::on_send_message_fail(int64 random_id, Status error) { } } else if (error.message() == "PEER_ID_INVALID") { error_code = 403; - if (td_->auth_manager_->is_bot()) { + if (td_->auth_manager_->is_bot() && + (dialog_id.get_type() == DialogType::User || dialog_id.get_type() == DialogType::SecretChat)) { error_message = "Bot can't initiate conversation with a user"; } } else if (error.message() == "WC_CONVERT_URL_INVALID" || error.message() == "EXTERNAL_URL_INVALID") {