2
0
mirror of https://github.com/ars3niy/tdlib-purple synced 2025-08-31 14:05:10 +00:00

More correct handling of responses when creating private chats at login

For successful response, this didn't really matter except for log
message, because the new chat was getting added anyway. For a failed
response, there would be invalid pointer cast and all kinds of problems.
This commit is contained in:
Arseniy Lartsev
2020-05-04 13:35:16 +02:00
parent 64f476ec98
commit 1b0f8f0e32

View File

@@ -332,10 +332,12 @@ void PurpleTdClient::requestMissingPrivateChats()
void PurpleTdClient::loginCreatePrivateChatResponse(uint64_t requestId, td::td_api::object_ptr<td::td_api::Object> object)
{
if (object->get_id() != td::td_api::chat::ID) {
if (object->get_id() == td::td_api::chat::ID) {
td::td_api::object_ptr<td::td_api::chat> chat = td::move_tl_object_as<td::td_api::chat>(object);
purple_debug_misc(config::pluginId, "Requested private chat received: id %lld\n",
(long long)chat->id_);
// Here the "new" chat already exists in AccountData because there has just been
// updateNewChat about this same chat. But do addChat anyway, just in case.
m_data.addChat(std::move(chat));
} else
purple_debug_misc(config::pluginId, "Failed to get requested private chat\n");