Skip to content

Commit

Permalink
Migrate ResolvePhoneAction to TDLib.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Sep 11, 2024
1 parent f84664b commit 3feffe8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Telegram/SourceFiles/core/phone_click_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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) {
Expand All @@ -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(
Expand Down

0 comments on commit 3feffe8

Please sign in to comment.