phone_banned_box.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "boxes/phone_banned_box.h"
  8. #include "ui/boxes/confirm_box.h"
  9. #include "core/click_handler_types.h" // UrlClickHandler
  10. #include "base/qthelp_url.h" // qthelp::url_encode
  11. #include "base/platform/base_platform_info.h"
  12. #include "window/window_controller.h"
  13. #include "lang/lang_keys.h"
  14. namespace Ui {
  15. namespace {
  16. void SendToBannedHelp(const QString &phone) {
  17. const auto version = QString::fromLatin1(AppVersionStr)
  18. + (cAlphaVersion()
  19. ? qsl(" alpha %1").arg(cAlphaVersion())
  20. : (AppBetaVersion ? " beta" : ""));
  21. const auto subject = qsl("Banned phone number: ") + phone;
  22. const auto body = qsl("\
  23. I'm trying to use my mobile phone number: ") + phone + qsl("\n\
  24. But Telegram says it's banned. Please help.\n\
  25. \n\
  26. App version: ") + version + qsl("\n\
  27. OS version: ") + ::Platform::SystemVersionPretty() + qsl("\n\
  28. Locale: ") + ::Platform::SystemLanguage();
  29. const auto url = "mailto:?to="
  30. + qthelp::url_encode("login@stel.com")
  31. + "&subject="
  32. + qthelp::url_encode(subject)
  33. + "&body="
  34. + qthelp::url_encode(body);
  35. UrlClickHandler::Open(url);
  36. }
  37. } // namespace
  38. void ShowPhoneBannedError(
  39. not_null<Window::Controller*> controller,
  40. const QString &phone) {
  41. const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
  42. const auto close = [=] {
  43. if (*box) {
  44. (*box)->closeBox();
  45. }
  46. };
  47. *box = controller->show(
  48. Ui::MakeConfirmBox({
  49. .text = tr::lng_signin_banned_text(),
  50. .cancelled = [=](Fn<void()> &&close) {
  51. SendToBannedHelp(phone);
  52. close();
  53. },
  54. .confirmText = tr::lng_box_ok(),
  55. .cancelText = tr::lng_signin_banned_help(),
  56. .strictCancel = true,
  57. }),
  58. Ui::LayerOption::CloseOther);
  59. }
  60. } // namespace Ui