MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / resolveApp

Method resolveApp

Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp:1060–1110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1058}
1059
1060void WebViewInstance::resolveApp(
1061 const QString &appname,
1062 const QString &startparam,
1063 ConfirmType confirmType) {
1064 const auto already = _session->data().findBotApp(_bot->id, appname);
1065 _requestId = _session->api().request(MTPmessages_GetBotApp(
1066 MTP_inputBotAppShortName(
1067 _bot->inputUser(),
1068 MTP_string(appname)),
1069 MTP_long(already ? already->hash : 0)
1070 )).done([=](const MTPmessages_BotApp &result) {
1071 _requestId = 0;
1072 const auto &data = result.data();
1073 const auto received = _session->data().processBotApp(
1074 _bot->id,
1075 data.vapp());
1076 _app = received ? received : already;
1077 _appStartParam = startparam;
1078 if (!_app) {
1079 _parentShow->showToast(tr::lng_username_app_not_found(tr::now));
1080 close();
1081 return;
1082 }
1083 const auto confirm = data.is_inactive()
1084 || (confirmType != ConfirmType::None);
1085 const auto writeAccess = result.data().is_request_write_access();
1086 const auto forceConfirmation = data.is_inactive()
1087 || (confirmType == ConfirmType::Always);
1088
1089 // Check if this app can be added to main menu.
1090 // On fail it'll still be opened.
1091 using Result = AttachWebView::AddToMenuResult;
1092 const auto done = crl::guard(this, [=](Result value, auto) {
1093 if (value == Result::Cancelled) {
1094 close();
1095 } else if (value != Result::Unsupported) {
1096 requestApp(true);
1097 } else if (confirm) {
1098 confirmAppOpen(writeAccess, [=](bool allowWrite) {
1099 requestApp(allowWrite);
1100 }, forceConfirmation);
1101 } else {
1102 requestApp(false);
1103 }
1104 });
1105 _session->attachWebView().requestAddToMenu(_bot, done);
1106 }).fail([=] {
1107 _parentShow->showToast(tr::lng_username_app_not_found(tr::now));
1108 close();
1109 }).send();
1110}
1111
1112void WebViewInstance::confirmOpen(Fn<void()> done, bool forceConfirmation) {
1113 if (!forceConfirmation

Callers

nothing calls this directly

Calls 13

MTP_stringFunction · 0.85
MTP_longFunction · 0.85
findBotAppMethod · 0.80
apiMethod · 0.80
inputUserMethod · 0.80
processBotAppMethod · 0.80
requestAddToMenuMethod · 0.80
dataMethod · 0.45
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected