Fix DialogActionManager::send_dialog_action in secret chats (#2756)

* Fix DialogActionManager::send_dialog_action in secret chats 

The code in `DialogActionManager::send_dialog_action` made the assumption that since we'd either have early returned or `DialogManager::have_input_peer` would be true, and therefore the else block of the conditional, which intended to set input_peer, should have done so successfully.

However, `DialogManager::have_input_peer` will return true for secret chats when `contacts_manager->have_input_encrypted_peer`
And `DialogManager::get_input_peer` will return a `nullptr` for secret chats by design (I believe this is because they operate using structures that are currently incompatible)

This should fix the root of a crash that happens when typing in or sending messages to secret chats on:
Telegram X 0.26.4.1678-arm64-v8a (99b10675)
TDLib: 1.8.23 (tdlib/td@4bafdc2)

* Move CHECK below SecretChat case instead per feedback
This commit is contained in:
Liru Færs 2024-01-14 17:02:56 -05:00 committed by GitHub
parent 58c457ab5f
commit 0f98d76683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -318,7 +318,6 @@ void DialogActionManager::send_dialog_action(DialogId dialog_id, MessageId top_t
}
input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
CHECK(input_peer != nullptr);
}
if (dialog_id.get_type() == DialogType::SecretChat) {
@ -328,6 +327,8 @@ void DialogActionManager::send_dialog_action(DialogId dialog_id, MessageId top_t
return;
}
CHECK(input_peer != nullptr);
auto new_query_ref =
td_->create_handler<SetTypingQuery>(std::move(promise))
->send(dialog_id, std::move(input_peer), top_thread_message_id, action.get_input_send_message_action());