From efce0f2309739607bf6a3328f0f852977387834b Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Wed, 15 Jan 2025 12:03:56 +0300 Subject: [PATCH] feat: search by ID on click Works only if number is recognized as phone by Telegram servers --- .../SourceFiles/core/phone_click_handler.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/core/phone_click_handler.cpp b/Telegram/SourceFiles/core/phone_click_handler.cpp index ec34b8f8b..a73ab7990 100644 --- a/Telegram/SourceFiles/core/phone_click_handler.cpp +++ b/Telegram/SourceFiles/core/phone_click_handler.cpp @@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "main/main_session.h" #include "mainwidget.h" +#include "ayu/utils/telegram_helpers.h" #include "mtproto/sender.h" #include "ui/effects/ripple_animation.h" #include "ui/painter.h" @@ -118,8 +119,24 @@ ResolvePhoneAction::ResolvePhoneAction( }); }).fail([=](const MTP::Error &error) { if (error.code() == 400) { - _peer.force_assign(nullptr); - _loaded.force_assign(true); + bool ok = false; + const auto possibleId = formattedPhone.toLongLong(&ok); + if (!ok) { + _peer.force_assign(nullptr); + _loaded.force_assign(true); + return; + } + + searchById(possibleId, + &controller->session(), + [=](const QString &username, UserData *user) + { + if (user) { + _peer = user; + } + + _loaded.force_assign(true); + }); } }).send(); }