diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 57509e3ea..a01aa5a88 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -4751,6 +4751,30 @@ bool MessagesManager::have_dialog_info(DialogId dialog_id) const { } } +bool MessagesManager::have_dialog_info_force(DialogId dialog_id) const { + switch (dialog_id.get_type()) { + case DialogType::User: { + UserId user_id = dialog_id.get_user_id(); + return td_->contacts_manager_->have_user_force(user_id); + } + case DialogType::Chat: { + ChatId chat_id = dialog_id.get_chat_id(); + return td_->contacts_manager_->have_chat_force(chat_id); + } + case DialogType::Channel: { + ChannelId channel_id = dialog_id.get_channel_id(); + return td_->contacts_manager_->have_channel_force(channel_id); + } + case DialogType::SecretChat: { + SecretChatId secret_chat_id = dialog_id.get_secret_chat_id(); + return td_->contacts_manager_->have_secret_chat_force(secret_chat_id); + } + case DialogType::None: + default: + return false; + } +} + tl_object_ptr MessagesManager::get_input_encrypted_chat( DialogId dialog_id, AccessRights access_rights) const { switch (dialog_id.get_type()) { @@ -11344,10 +11368,12 @@ Status MessagesManager::set_dialog_client_data(DialogId dialog_id, string &&clie void MessagesManager::create_dialog(DialogId dialog_id, Promise &&promise) { if (!have_input_peer(dialog_id, AccessRights::Read)) { - if (!have_dialog_info(dialog_id)) { + if (!have_dialog_info_force(dialog_id)) { return promise.set_error(Status::Error(6, "Chat info not found")); } - return promise.set_error(Status::Error(6, "Can't access the chat")); + if (!have_input_peer(dialog_id, AccessRights::Read)) { + return promise.set_error(Status::Error(6, "Can't access the chat")); + } } if (td_->auth_manager_->is_bot() || dialog_id.get_type() == DialogType::SecretChat) { diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 64f7d5dfd..6f765bede 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -2117,6 +2117,7 @@ class MessagesManager : public Actor { tl_object_ptr get_chat_object(const Dialog *d); bool have_dialog_info(DialogId dialog_id) const; + bool have_dialog_info_force(DialogId dialog_id) const; Dialog *get_dialog(DialogId dialog_id); const Dialog *get_dialog(DialogId dialog_id) const;