From 699f3e1ed2b2f6f7a1cb104abd1de6db195a02f1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 11 Sep 2024 14:41:39 +0400 Subject: [PATCH] Migrate ResolvePhoneAction to TDLib. --- .../SourceFiles/core/phone_click_handler.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Telegram/SourceFiles/core/phone_click_handler.cpp b/Telegram/SourceFiles/core/phone_click_handler.cpp index 19d15b78a7e571..cfaafa8204fc80 100644 --- a/Telegram/SourceFiles/core/phone_click_handler.cpp +++ b/Telegram/SourceFiles/core/phone_click_handler.cpp @@ -26,8 +26,13 @@ For license and copyright information please follow this link: #include "styles/style_chat.h" // popupMenuExpandedSeparator. #include "styles/style_menu_icons.h" +#include "tdb/tdb_sender.h" +#include "tdb/tdb_tl_scheme.h" + namespace { +using namespace Tdb; + [[nodiscard]] QString Trim(QString text) { return text .replace('+', QString()) @@ -101,6 +106,7 @@ ResolvePhoneAction::ResolvePhoneAction( _peer = peer; _loaded.force_assign(true); } else { +#if 0 // mtp _api.request(MTPcontacts_ResolvePhone( MTP_string(phone) )).done([=](const MTPcontacts_ResolvedPeer &result) { @@ -118,6 +124,19 @@ ResolvePhoneAction::ResolvePhoneAction( _loaded.force_assign(true); } }).send(); +#endif + _api.request(TLsearchUserByPhoneNumber( + tl_string(phone), + tl_bool(false) + )).done([=](const TLuser &result) { + _peer = owner->processUser(result); + _loaded.force_assign(true); + }).fail([=](const Error &error) { + if (error.code == 404) { + _peer.force_assign(nullptr); + _loaded.force_assign(true); + } + }).send(); } paintRequest(