Skip to content

Commit

Permalink
Migrate grossing apps and main app to TDLib.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 7, 2024
1 parent d8cc38d commit 6e902c5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,19 @@ void WebViewInstance::requestSimple() {
}

void WebViewInstance::requestMain() {
_requestId = _session->sender().request(TLgetMainWebApp(
peerToTdbChat(_context.action->history->peer->id),
tl_int53(peerToUser(_bot->id).bare),
tl_string(_button.startCommand),
Window::Theme::WebViewTheme(),
tl_string("tdesktop")
)).done([=](const TLmainWebApp &result) {
show(qs(result.data().vurl()));
}).fail([=](const Error &error) {
_parentShow->showToast(error.message);
close();
}).send();
#if 0 // mtp
using Flag = MTPmessages_RequestMainWebView::Flag;
_requestId = _session->api().request(MTPmessages_RequestMainWebView(
MTP_flags(Flag::f_theme_params
Expand All @@ -1097,6 +1110,7 @@ void WebViewInstance::requestMain() {
_parentShow->showToast(error.type());
close();
}).send();
#endif
}

void WebViewInstance::requestApp(bool allowWrite) {
Expand Down Expand Up @@ -1765,7 +1779,10 @@ AttachWebView::AttachWebView(not_null<Main::Session*> session)

AttachWebView::~AttachWebView() {
closeAll();
#if 0 // mtp
_session->api().request(_popularAppBotsRequestId).cancel();
#endif
_session->sender().request(_popularAppBotsRequestId).cancel();
}

void AttachWebView::openByUsername(
Expand Down Expand Up @@ -1827,18 +1844,31 @@ void AttachWebView::loadPopularAppBots() {
if (_popularAppBotsLoaded.current() || _popularAppBotsRequestId) {
return;
}
#if 0 // mtp
_popularAppBotsRequestId = _session->api().request(
MTPbots_GetPopularAppBots(
MTP_string(),
MTP_int(kPopularAppBotsLimit))
).done([=](const MTPbots_PopularAppBots &result) {
#endif
_popularAppBotsRequestId = _session->sender().request(
TLgetGrossingWebAppBots(
tl_string(), // offset
tl_int32(kPopularAppBotsLimit))
).done([=](const TLfoundUsers &result) {
_popularAppBotsRequestId = 0;

#if 0 // mtp
const auto &list = result.data().vusers().v;
#endif
const auto &list = result.data().vuser_ids().v;
auto parsed = std::vector<not_null<UserData*>>();
parsed.reserve(list.size());
for (const auto &user : list) {
#if 0 // mtp
const auto bot = _session->data().processUser(user);
#endif
const auto bot = _session->data().user(UserId(user.v));
if (bot->isBot()) {
parsed.push_back(bot);
}
Expand Down

0 comments on commit 6e902c5

Please sign in to comment.