ZaStoGram_desktop/Telegram/SourceFiles/window/window_session_controller_contact.cpp
loop-uh b40c425ad2 Новые файлы оригинала: include-пути mtproto по раскладке форка
api_share_themes.h, wallet/*, info/profile/*, window/* и test/* пришли из оригинала
со старыми путями mtproto/sender.h, mtp_instance.h, mtproto_dc_options.h,
mtproto_response.h, details/mtproto_serialized_request.h, details/mtproto_dump_to_text.h.
Переписаны на instance/, config/, protocol/ (apiwrap.cpp не собирался).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 17:03:07 -05:00

62 lines
1.8 KiB
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "window/window_session_controller.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "mtproto/protocol/mtproto_response.h"
namespace Window {
void SessionNavigation::resolveContactToken(
const QString &token,
Fn<void(not_null<PeerData*>)> done) {
if (_contactTokenRequestId && _contactToken == token) {
_contactTokenDone = std::move(done);
return;
}
cancelContactTokenResolve();
_contactToken = token;
_contactTokenDone = std::move(done);
_contactTokenRequestId = _api.request(MTPcontacts_ImportContactToken(
MTP_string(token)
)).done([=](const MTPUser &result) {
_contactTokenRequestId = 0;
_contactToken.clear();
const auto done = crl::guard(this, base::take(_contactTokenDone));
const auto weak = base::make_weak(this);
const auto user = _session->data().processUser(result);
if (const auto strong = weak.get()) {
if (user->isInaccessible()) {
strong->showToast(tr::lng_contact_link_invalid(tr::now));
return;
}
strong->parentController()->hideLayer();
done(user);
}
}).fail([=](const MTP::Error &error) {
_contactTokenRequestId = 0;
_contactToken.clear();
_contactTokenDone = nullptr;
if (!MTP::IgnoreError(error)) {
showToast(MTP::IsFloodError(error)
? tr::lng_flood_error(tr::now)
: tr::lng_contact_link_invalid(tr::now));
}
}).handleAllErrors().send();
}
void SessionNavigation::cancelContactTokenResolve() {
_api.request(base::take(_contactTokenRequestId)).cancel();
_contactToken.clear();
_contactTokenDone = nullptr;
}
} // namespace Window