Moved ShowPhoneBannedError to separated file.

This commit is contained in:
23rd 2021-10-18 19:32:50 +03:00
parent c6e1b14429
commit f9976005f7
7 changed files with 95 additions and 48 deletions

View File

@ -223,6 +223,8 @@ PRIVATE
boxes/peer_lists_box.h
boxes/passcode_box.cpp
boxes/passcode_box.h
boxes/phone_banned_box.cpp
boxes/phone_banned_box.h
boxes/rate_call_box.cpp
boxes/rate_call_box.h
boxes/self_destruction_box.cpp

View File

@ -9,14 +9,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/sent_code_field.h"
#include "ui/wrap/fade_wrap.h"
#include "ui/toast/toast.h"
#include "ui/text/format_values.h" // Ui::FormatPhone
#include "ui/text/text_utilities.h"
#include "ui/special_fields.h"
#include "boxes/confirm_phone_box.h"
#include "boxes/confirm_box.h"
#include "boxes/phone_banned_box.h"
#include "countries/countries_instance.h" // Countries::ExtractPhoneCode.
#include "main/main_session.h"
#include "data/data_session.h"
@ -231,7 +231,7 @@ void ChangePhoneBox::EnterPhone::sendPhoneFail(const MTP::Error &error, const QS
} else if (error.type() == qstr("PHONE_NUMBER_INVALID")) {
showError(tr::lng_bad_phone(tr::now));
} else if (error.type() == qstr("PHONE_NUMBER_BANNED")) {
ShowPhoneBannedError(phoneNumber);
Ui::ShowPhoneBannedError(&_controller->window(), phoneNumber);
} else if (error.type() == qstr("PHONE_NUMBER_OCCUPIED")) {
_controller->show(
Box<InformBox>(

View File

@ -27,49 +27,8 @@ namespace {
object_ptr<ConfirmPhoneBox> CurrentConfirmPhoneBox = { nullptr };
void SendToBannedHelp(const QString &phone) {
const auto version = QString::fromLatin1(AppVersionStr)
+ (cAlphaVersion()
? qsl(" alpha %1").arg(cAlphaVersion())
: (AppBetaVersion ? " beta" : ""));
const auto subject = qsl("Banned phone number: ") + phone;
const auto body = qsl("\
I'm trying to use my mobile phone number: ") + phone + qsl("\n\
But Telegram says it's banned. Please help.\n\
\n\
App version: ") + version + qsl("\n\
OS version: ") + Platform::SystemVersionPretty() + qsl("\n\
Locale: ") + Platform::SystemLanguage();
const auto url = "mailto:?to="
+ qthelp::url_encode("login@stel.com")
+ "&subject="
+ qthelp::url_encode(subject)
+ "&body="
+ qthelp::url_encode(body);
UrlClickHandler::Open(url);
}
} // namespace
void ShowPhoneBannedError(const QString &phone) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
const auto close = [=] {
if (*box) {
(*box)->closeBox();
}
};
*box = Ui::show(Box<ConfirmBox>(
tr::lng_signin_banned_text(tr::now),
tr::lng_box_ok(tr::now),
tr::lng_signin_banned_help(tr::now),
close,
[=] { SendToBannedHelp(phone); close(); }));
}
void ConfirmPhoneBox::Start(
not_null<Main::Session*> session,
const QString &phone,

View File

@ -22,8 +22,6 @@ namespace Main {
class Session;
} // namespace Main
void ShowPhoneBannedError(const QString &phone);
class ConfirmPhoneBox final : public Ui::BoxContent {
public:
static void Start(

View File

@ -0,0 +1,68 @@
/*
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 "boxes/phone_banned_box.h"
#include "boxes/confirm_box.h"
#include "core/click_handler_types.h" // UrlClickHandler
#include "base/qthelp_url.h" // qthelp::url_encode
#include "base/platform/base_platform_info.h"
#include "window/window_controller.h"
#include "lang/lang_keys.h"
namespace Ui {
namespace {
void SendToBannedHelp(const QString &phone) {
const auto version = QString::fromLatin1(AppVersionStr)
+ (cAlphaVersion()
? qsl(" alpha %1").arg(cAlphaVersion())
: (AppBetaVersion ? " beta" : ""));
const auto subject = qsl("Banned phone number: ") + phone;
const auto body = qsl("\
I'm trying to use my mobile phone number: ") + phone + qsl("\n\
But Telegram says it's banned. Please help.\n\
\n\
App version: ") + version + qsl("\n\
OS version: ") + ::Platform::SystemVersionPretty() + qsl("\n\
Locale: ") + ::Platform::SystemLanguage();
const auto url = "mailto:?to="
+ qthelp::url_encode("login@stel.com")
+ "&subject="
+ qthelp::url_encode(subject)
+ "&body="
+ qthelp::url_encode(body);
UrlClickHandler::Open(url);
}
} // namespace
void ShowPhoneBannedError(
not_null<Window::Controller*> controller,
const QString &phone) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
const auto close = [=] {
if (*box) {
(*box)->closeBox();
}
};
*box = controller->show(
Box<ConfirmBox>(
tr::lng_signin_banned_text(tr::now),
tr::lng_box_ok(tr::now),
tr::lng_signin_banned_help(tr::now),
close,
[=] { SendToBannedHelp(phone); close(); }),
Ui::LayerOption::CloseOther);
}
} // namespace Ui

View File

@ -0,0 +1,20 @@
/*
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
*/
#pragma once
namespace Window {
class Controller;
} // namespace Window
namespace Ui {
void ShowPhoneBannedError(
not_null<Window::Controller*> controller,
const QString &phone);
} // namespace Ui

View File

@ -20,8 +20,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_app_config.h"
#include "main/main_session.h"
#include "data/data_user.h"
#include "boxes/confirm_phone_box.h"
#include "boxes/confirm_box.h"
#include "boxes/phone_banned_box.h"
#include "core/application.h"
namespace Intro {
@ -240,7 +240,7 @@ void PhoneWidget::phoneSubmitFail(const MTP::Error &error) {
} else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error
showPhoneError(tr::lng_bad_phone());
} else if (err == qstr("PHONE_NUMBER_BANNED")) {
ShowPhoneBannedError(_sentPhone);
Ui::ShowPhoneBannedError(getData()->controller, _sentPhone);
} else if (Logs::DebugEnabled()) { // internal server error
showPhoneError(rpl::single(err + ": " + error.description()));
} else {