diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 6890d54ad1..16b3b2240f 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4760,6 +4760,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_url_auth_login_title" = "Log in to {domain}"; "lng_url_auth_login_button" = "Log in"; "lng_url_auth_site_access" = "This site will receive your **name**, **username** and **profile photo**."; +"lng_url_auth_app_access" = "This app will receive your **name**, **username** and **profile photo**."; +"lng_url_auth_unverified_app" = "Unverified App"; "lng_url_auth_device_label" = "Device"; "lng_url_auth_ip_label" = "IP Address"; "lng_url_auth_login_attempt" = "This login attempt came from the device above."; diff --git a/Telegram/SourceFiles/boxes/url_auth_box.cpp b/Telegram/SourceFiles/boxes/url_auth_box.cpp index a0e72efed9..3fb201ff45 100644 --- a/Telegram/SourceFiles/boxes/url_auth_box.cpp +++ b/Telegram/SourceFiles/boxes/url_auth_box.cpp @@ -396,11 +396,16 @@ void RequestButton( }).send(); } }; + const auto displayName = request.is_is_app() + ? (request.vverified_app_name() + ? qs(*request.vverified_app_name()) + : tr::lng_url_auth_unverified_app(tr::now)) + : qs(request.vdomain()); *box = show->show( Box( Show, url, - qs(request.vdomain()), + displayName, session->user()->name(), bot->firstName, callback), @@ -425,7 +430,12 @@ void RequestUrl( : nullptr; const auto requestPhone = request.is_request_phone_number(); const auto matchCodesFirst = request.is_match_codes_first(); - const auto domain = qs(request.vdomain()); + const auto isApp = request.is_is_app(); + const auto domain = isApp + ? (request.vverified_app_name() + ? qs(*request.vverified_app_name()) + : tr::lng_url_auth_unverified_app(tr::now)) + : qs(request.vdomain()); const auto userIdHint = request.vuser_id_hint() ? peerToUser(peerFromUser(*request.vuser_id_hint())) : UserId(); @@ -495,6 +505,9 @@ void RequestUrl( return url; }); finishWithUrl(to, accepted); + const auto domainWrapped = isApp + ? tr::bold(domain) + : tr::link(domain); show->showToast(Ui::Toast::Config{ .title = tr::lng_url_auth_phone_toast_good_title(tr::now), .text = ((requestPhone && !sharePhone) @@ -502,17 +515,20 @@ void RequestUrl( : tr::lng_url_auth_phone_toast_good)( tr::now, lt_domain, - tr::link(domain), + domainWrapped, tr::marked), .duration = crl::time(4000), }); }).fail([=] { + const auto domainWrapped = isApp + ? tr::bold(domain) + : tr::link(domain); show->showToast(Ui::Toast::Config{ .title = tr::lng_url_auth_phone_toast_bad_title(tr::now), .text = tr::lng_url_auth_phone_toast_bad( tr::now, lt_domain, - tr::link(domain), + domainWrapped, tr::marked), .duration = crl::time(4000), }); @@ -585,7 +601,10 @@ void RequestUrl( Ui::ConfirmBoxArgs{ .text = tr::lng_url_auth_phone_sure_text( lt_domain, - rpl::single(tr::bold(capitalized(domain))), + rpl::single( + tr::bold(isApp + ? domain + : capitalized(domain))), lt_phone, PhoneValue(currentSession->user()), tr::rich), @@ -618,7 +637,8 @@ void RequestUrl( region, (matchCodesFirst ? (rpl::single(QStringList()) | rpl::type_erased) - : matchCodesShared->value())); + : matchCodesShared->value()), + isApp); *accountResult = AddAccountsMenu( box->verticalLayout(), @@ -669,7 +689,8 @@ void RequestUrl( tr::now) : error.type()); }).send(); - }); + }, + isApp); }), Ui::LayerOption::KeepOther); matchCodesBox->boxClosing() | rpl::on_next([=] { diff --git a/Telegram/SourceFiles/boxes/url_auth_box_content.cpp b/Telegram/SourceFiles/boxes/url_auth_box_content.cpp index fbbd0a0a25..291be3d8d1 100644 --- a/Telegram/SourceFiles/boxes/url_auth_box_content.cpp +++ b/Telegram/SourceFiles/boxes/url_auth_box_content.cpp @@ -50,7 +50,8 @@ void ShowMatchCodesBox( Fn(QString)> emojiImageFactory, const QString &domain, const QStringList &codes, - Fn callback) { + Fn callback, + bool isApp) { box->setWidth(st::boxWidth); box->setStyle(st::urlAuthBox); @@ -175,8 +176,8 @@ void ShowMatchCodesBox( Ui::AddSkip(content); - const auto domainUrl = qthelp::validate_url(domain); - if (!domainUrl.isEmpty()) { + const auto domainUrl = isApp ? QString() : qthelp::validate_url(domain); + if (!domainUrl.isEmpty() || isApp) { Ui::AddSkip(content); Ui::AddSkip(content); content->add( @@ -184,7 +185,9 @@ void ShowMatchCodesBox( content, tr::lng_url_auth_login_title( lt_domain, - rpl::single(Ui::Text::Link(domain, domainUrl)), + rpl::single(isApp + ? tr::bold(domain) + : Ui::Text::Link(domain, domainUrl)), tr::marked), st::urlAuthCheckboxAbout), st::boxRowPadding, @@ -433,7 +436,8 @@ void ShowDetails( const QString &platform, const QString &ip, const QString ®ion, - rpl::producer matchCodes) { + rpl::producer matchCodes, + bool isApp) { box->setWidth(st::boxWidth); box->setStyle(st::urlAuthBox); @@ -451,7 +455,7 @@ void ShowDetails( Ui::AddSkip(content); } - const auto domainUrl = qthelp::validate_url(domain); + const auto domainUrl = isApp ? QString() : qthelp::validate_url(domain); const auto userpicButtonWidth = st::restoreUserpicIcon.photoSize; const auto titlePadding = style::margins( st::boxRowPadding.left(), @@ -461,12 +465,17 @@ void ShowDetails( content->add( object_ptr( content, - domainUrl.isEmpty() - ? tr::lng_url_auth_login_button(tr::marked) - : tr::lng_url_auth_login_title( + (isApp + ? tr::lng_url_auth_login_title( lt_domain, - rpl::single(Ui::Text::Link(domain, domainUrl)), - tr::marked), + rpl::single(tr::bold(domain)), + tr::marked) + : domainUrl.isEmpty() + ? tr::lng_url_auth_login_button(tr::marked) + : tr::lng_url_auth_login_title( + lt_domain, + rpl::single(Ui::Text::Link(domain, domainUrl)), + tr::marked)), st::boxTitle), titlePadding, style::al_top); @@ -475,7 +484,9 @@ void ShowDetails( content->add( object_ptr( content, - tr::lng_url_auth_site_access(tr::rich), + (isApp + ? tr::lng_url_auth_app_access(tr::rich) + : tr::lng_url_auth_site_access(tr::rich)), st::urlAuthCheckboxAbout), st::boxRowPadding); @@ -564,7 +575,8 @@ void ShowDetails( && allowMessages->toggled()), .matchCode = std::move(matchCode), }); - }); + }, + isApp); })); }); } diff --git a/Telegram/SourceFiles/boxes/url_auth_box_content.h b/Telegram/SourceFiles/boxes/url_auth_box_content.h index 5d0886cd20..838aac7e54 100644 --- a/Telegram/SourceFiles/boxes/url_auth_box_content.h +++ b/Telegram/SourceFiles/boxes/url_auth_box_content.h @@ -58,7 +58,8 @@ void ShowMatchCodesBox( Fn(QString)> emojiImageFactory, const QString &domain, const QStringList &codes, - Fn callback); + Fn callback, + bool isApp = false); void Show( not_null box, @@ -80,6 +81,7 @@ void ShowDetails( const QString &platform, const QString &ip, const QString ®ion, - rpl::producer matchCodes = rpl::single(QStringList())); + rpl::producer matchCodes = rpl::single(QStringList()), + bool isApp = false); } // namespace UrlAuthBox