mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Update API scheme on layer 140.
This commit is contained in:
parent
20bdbf531a
commit
df15ff9f8e
18 changed files with 157 additions and 66 deletions
|
@ -1299,6 +1299,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_action_proximity_distance_m#other" = "{count} metres";
|
||||
"lng_action_proximity_distance_km#one" = "{count} km";
|
||||
"lng_action_proximity_distance_km#other" = "{count} km";
|
||||
"lng_action_webview_data_done" = "You have just successfully transferred data from the «{text}» button to the bot.";
|
||||
|
||||
"lng_ttl_photo_received" = "{from} sent you a self-destructing photo. Please view it on your mobile.";
|
||||
"lng_ttl_photo_sent" = "You sent a self-destructing photo.";
|
||||
|
|
|
@ -129,7 +129,7 @@ channel#8261ac61 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.
|
|||
channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat;
|
||||
|
||||
chatFull#d18ee226 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector<long> available_reactions:flags.18?Vector<string> = ChatFull;
|
||||
channelFull#e13c3d20 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector<string> groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector<long> default_send_as:flags.29?Peer available_reactions:flags.30?Vector<string> = ChatFull;
|
||||
channelFull#ea68a619 flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector<string> groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector<long> default_send_as:flags.29?Peer available_reactions:flags.30?Vector<string> = ChatFull;
|
||||
|
||||
chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant;
|
||||
chatParticipantCreator#e46bcee4 user_id:long = ChatParticipant;
|
||||
|
@ -189,6 +189,8 @@ messageActionSetMessagesTTL#aa1afbfd period:int = MessageAction;
|
|||
messageActionGroupCallScheduled#b3a07661 call:InputGroupCall schedule_date:int = MessageAction;
|
||||
messageActionSetChatTheme#aa786345 emoticon:string = MessageAction;
|
||||
messageActionChatJoinedByRequest#ebbca3cb = MessageAction;
|
||||
messageActionWebViewDataSentMe#47dd8079 text:string data:string = MessageAction;
|
||||
messageActionWebViewDataSent#b4c38cb5 text:string = MessageAction;
|
||||
|
||||
dialog#a8edd0f5 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog;
|
||||
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
|
||||
|
@ -385,6 +387,7 @@ updatePendingJoinRequests#7063c3db peer:Peer requests_pending:int recent_request
|
|||
updateBotChatInviteRequester#11dfa986 peer:Peer date:int user_id:long about:string invite:ExportedChatInvite qts:int = Update;
|
||||
updateMessageReactions#154798c3 peer:Peer msg_id:int reactions:MessageReactions = Update;
|
||||
updateAttachMenuBots#17b7a20b = Update;
|
||||
updateWebViewResultSent#f8f63baa peer:Peer bot_id:long query_id:long = Update;
|
||||
|
||||
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
|
||||
|
||||
|
@ -592,6 +595,7 @@ keyboardButtonRequestPoll#bbc7515d flags:# quiz:flags.0?Bool text:string = Keybo
|
|||
inputKeyboardButtonUserProfile#e988037b text:string user_id:InputUser = KeyboardButton;
|
||||
keyboardButtonUserProfile#308660c1 text:string user_id:long = KeyboardButton;
|
||||
keyboardButtonWebView#13767230 text:string url:string = KeyboardButton;
|
||||
keyboardButtonSimpleWebView#a0c0505c text:string url:string = KeyboardButton;
|
||||
|
||||
keyboardButtonRow#77608b83 buttons:Vector<KeyboardButton> = KeyboardButtonRow;
|
||||
|
||||
|
@ -1331,15 +1335,19 @@ phone.groupCallStreamChannels#d0e482b2 channels:Vector<GroupCallStreamChannel> =
|
|||
|
||||
phone.groupCallStreamRtmpUrl#2dbf3432 url:string key:string = phone.GroupCallStreamRtmpUrl;
|
||||
|
||||
attachMenuBot#d47e3658 bot_id:long attach_menu_icon:Document = AttachMenuBot;
|
||||
attachMenuBot#4fdf05a8 flags:# inactive:flags.0?true bot_id:long attach_menu_name:string attach_menu_icon:Document = AttachMenuBot;
|
||||
|
||||
attachMenuBotsNotModified#f1d88a5c = AttachMenuBots;
|
||||
attachMenuBots#3c4301c0 hash:long bots:Vector<AttachMenuBot> users:Vector<User> = AttachMenuBots;
|
||||
|
||||
attachMenuBotsBot#93bf667f bot:AttachMenuBot users:Vector<User> = AttachMenuBotsBot;
|
||||
|
||||
webViewResultUrl#c14557c query_id:long url:string = WebViewResult;
|
||||
webViewResultConfirmationRequired#b1cad385 bot:AttachMenuBot users:Vector<User> = WebViewResult;
|
||||
|
||||
messages.webViewResult#aadf159b result:BotInlineResult users:Vector<User> = messages.WebViewResult;
|
||||
simpleWebViewResultUrl#882f76bb url:string = SimpleWebViewResult;
|
||||
|
||||
webViewMessageSent#c94511c flags:# msg_id:flags.0?InputBotInlineMessageID = WebViewMessageSent;
|
||||
|
||||
---functions---
|
||||
|
||||
|
@ -1631,10 +1639,13 @@ messages.getUnreadReactions#e85bae1a peer:InputPeer offset_id:int add_offset:int
|
|||
messages.readReactions#82e251d7 peer:InputPeer = messages.AffectedHistory;
|
||||
messages.searchSentMedia#107e31a0 q:string filter:MessagesFilter limit:int = messages.Messages;
|
||||
messages.getAttachMenuBots#16fcc2cb hash:long = AttachMenuBots;
|
||||
messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot;
|
||||
messages.toggleBotInAttachMenu#1aee33af bot:InputUser enabled:Bool = Bool;
|
||||
messages.requestWebView#a17c10db flags:# peer:InputPeer bot:InputUser url:flags.0?string theme_params:flags.1?DataJSON = WebViewResult;
|
||||
messages.setWebViewResult#e41cd11d query_id:long result:InputBotInlineResult = Bool;
|
||||
messages.getWebViewResult#22b6c214 peer:InputPeer bot:InputUser query_id:long = messages.WebViewResult;
|
||||
messages.requestWebView#2221fe98 flags:# silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string theme_params:flags.2?DataJSON reply_to_msg_id:flags.0?int = WebViewResult;
|
||||
messages.prolongWebView#d22ad148 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int = Bool;
|
||||
messages.requestSimpleWebView#6abb2f73 flags:# bot:InputUser url:string theme_params:flags.0?DataJSON = SimpleWebViewResult;
|
||||
messages.sendWebViewResultMessage#ddcf50eb query_id:long result:InputBotInlineResult = WebViewMessageSent;
|
||||
messages.sendWebViewData#dc0242c8 bot:InputUser random_id:long button_text:string data:string = Updates;
|
||||
|
||||
updates.getState#edd4882a = updates.State;
|
||||
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
||||
|
@ -1702,7 +1713,7 @@ channels.editBanned#96e6cd81 channel:InputChannel participant:InputPeer banned_r
|
|||
channels.getAdminLog#33ddf480 flags:# channel:InputChannel q:string events_filter:flags.0?ChannelAdminLogEventsFilter admins:flags.1?Vector<InputUser> max_id:long min_id:long limit:int = channels.AdminLogResults;
|
||||
channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = Bool;
|
||||
channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector<int> = Bool;
|
||||
channels.deleteHistory#af369d42 channel:InputChannel max_id:int = Bool;
|
||||
channels.deleteHistory#9baa9647 flags:# for_everyone:flags.0?true channel:InputChannel max_id:int = Updates;
|
||||
channels.togglePreHistoryHidden#eabbb94c channel:InputChannel enabled:Bool = Updates;
|
||||
channels.getLeftChannels#8341ecc0 offset:int = messages.Chats;
|
||||
channels.getGroupsForDiscussion#f5dad378 = messages.Chats;
|
||||
|
|
|
@ -642,6 +642,7 @@ void Histories::deleteAllMessages(
|
|||
}).send();
|
||||
} else if (channel) {
|
||||
return session().api().request(MTPchannels_DeleteHistory(
|
||||
MTP_flags(0),
|
||||
channel->inputChannel,
|
||||
MTP_int(deleteTillId)
|
||||
)).done(finish).fail(finish).send();
|
||||
|
|
|
@ -1130,6 +1130,12 @@ ServiceAction ParseServiceAction(
|
|||
};
|
||||
}, [&](const MTPDmessageActionChatJoinedByRequest &data) {
|
||||
result.content = ActionChatJoinedByRequest();
|
||||
}, [&](const MTPDmessageActionWebViewDataSentMe &data) {
|
||||
// Should not be in user inbox.
|
||||
}, [&](const MTPDmessageActionWebViewDataSent &data) {
|
||||
auto content = ActionWebViewDataSent();
|
||||
content.text = ParseString(data.vtext());
|
||||
result.content = content;
|
||||
}, [](const MTPDmessageActionEmpty &data) {});
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -482,6 +482,10 @@ struct ActionSetChatTheme {
|
|||
struct ActionChatJoinedByRequest {
|
||||
};
|
||||
|
||||
struct ActionWebViewDataSent {
|
||||
Utf8String text;
|
||||
};
|
||||
|
||||
struct ServiceAction {
|
||||
std::variant<
|
||||
v::null_t,
|
||||
|
@ -512,7 +516,8 @@ struct ServiceAction {
|
|||
ActionSetMessagesTTL,
|
||||
ActionGroupCallScheduled,
|
||||
ActionSetChatTheme,
|
||||
ActionChatJoinedByRequest> content;
|
||||
ActionChatJoinedByRequest,
|
||||
ActionWebViewDataSent> content;
|
||||
};
|
||||
|
||||
ServiceAction ParseServiceAction(
|
||||
|
|
|
@ -1113,6 +1113,10 @@ auto HtmlWriter::Wrap::pushMessage(
|
|||
}, [&](const ActionChatJoinedByRequest &data) {
|
||||
return serviceFrom
|
||||
+ " joined group by request";
|
||||
}, [&](const ActionWebViewDataSent &data) {
|
||||
return "You have just successfully transferred data from the «"
|
||||
+ SerializeString(data.text)
|
||||
+ "» button to the bot";
|
||||
}, [](v::null_t) { return QByteArray(); });
|
||||
|
||||
if (!serviceText.isEmpty()) {
|
||||
|
|
|
@ -527,6 +527,9 @@ QByteArray SerializeMessage(
|
|||
}, [&](const ActionChatJoinedByRequest &data) {
|
||||
pushActor();
|
||||
pushAction("join_group_by_request");
|
||||
}, [&](const ActionWebViewDataSent &data) {
|
||||
pushAction("send_webview_data");
|
||||
push("text", data.text);
|
||||
}, [](v::null_t) {});
|
||||
|
||||
if (v::is_null(message.action.content)) {
|
||||
|
|
|
@ -226,6 +226,16 @@ void activateBotCommand(
|
|||
if (const auto bot = msg->getMessageBot()) {
|
||||
m->controller()->requestAttachWebview(
|
||||
bot,
|
||||
bot,
|
||||
{ .text = button->text, .url = button->data });
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case ButtonType::SimpleWebView: {
|
||||
if (const auto m = CheckMainWidget(&msg->history()->session())) {
|
||||
if (const auto bot = msg->getMessageBot()) {
|
||||
m->controller()->requestAttachSimpleWebview(
|
||||
bot,
|
||||
button->data);
|
||||
}
|
||||
|
|
|
@ -126,6 +126,11 @@ void HistoryMessageMarkupData::fillRows(
|
|||
Type::WebView,
|
||||
qs(data.vtext()),
|
||||
data.vurl().v);
|
||||
}, [&](const MTPDkeyboardButtonSimpleWebView &data) {
|
||||
row.emplace_back(
|
||||
Type::SimpleWebView,
|
||||
qs(data.vtext()),
|
||||
data.vurl().v);
|
||||
});
|
||||
}
|
||||
if (!row.empty()) {
|
||||
|
|
|
@ -42,6 +42,7 @@ struct HistoryMessageMarkupButton {
|
|||
Auth,
|
||||
UserProfile,
|
||||
WebView,
|
||||
SimpleWebView,
|
||||
};
|
||||
|
||||
HistoryMessageMarkupButton(
|
||||
|
|
|
@ -606,6 +606,16 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
|||
return result;
|
||||
};
|
||||
|
||||
auto prepareWebViewDataSent = [this](const MTPDmessageActionWebViewDataSent &action) {
|
||||
auto result = PreparedText{};
|
||||
result.text = tr::lng_action_webview_data_done(
|
||||
tr::now,
|
||||
lt_text,
|
||||
{ .text = qs(action.vtext()) },
|
||||
Ui::Text::WithEntities);
|
||||
return result;
|
||||
};
|
||||
|
||||
const auto messageText = action.match([&](
|
||||
const MTPDmessageActionChatAddUser &data) {
|
||||
return prepareChatAddUserText(data);
|
||||
|
@ -671,6 +681,13 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
|
|||
return prepareSetChatTheme(data);
|
||||
}, [&](const MTPDmessageActionChatJoinedByRequest &data) {
|
||||
return prepareChatJoinedByRequest(data);
|
||||
}, [&](const MTPDmessageActionWebViewDataSent &data) {
|
||||
return prepareWebViewDataSent(data);
|
||||
}, [&](const MTPDmessageActionWebViewDataSentMe &data) {
|
||||
LOG(("API Error: messageActionWebViewDataSentMe received."));
|
||||
return PreparedText{
|
||||
tr::lng_message_empty(tr::now, Ui::Text::WithEntities)
|
||||
};
|
||||
}, [](const MTPDmessageActionEmpty &) {
|
||||
return PreparedText{
|
||||
tr::lng_message_empty(tr::now, Ui::Text::WithEntities)
|
||||
|
|
|
@ -1021,9 +1021,7 @@ void HistoryWidget::initTabbedSelector() {
|
|||
sendExistingPhoto(data.photo, data.options);
|
||||
}, lifetime());
|
||||
|
||||
rpl::merge(
|
||||
selector->inlineResultChosen(),
|
||||
controller()->inlineResultConfirmed()
|
||||
selector->inlineResultChosen(
|
||||
) | filter | rpl::filter([=](const Selector::InlineChosen &data) {
|
||||
if (!data.recipientOverride) {
|
||||
return true;
|
||||
|
|
|
@ -73,6 +73,7 @@ enum {
|
|||
mtpc_vector = tl::id_vector,
|
||||
mtpc_bytes = tl::id_bytes,
|
||||
mtpc_flags = tl::id_flags,
|
||||
mtpc_flags64 = tl::id_flags64,
|
||||
|
||||
// layers
|
||||
mtpc_invokeWithLayer1 = 0x53835315,
|
||||
|
|
|
@ -66,19 +66,22 @@ Panel::Progress::Progress(QWidget *parent, Fn<QRect()> rect)
|
|||
st::paymentsLoading) {
|
||||
}
|
||||
|
||||
Panel::Panel(const QString &userDataPath, Fn<void()> send, Fn<void()> close)
|
||||
Panel::Panel(
|
||||
const QString &userDataPath,
|
||||
Fn<void(QByteArray)> sendData,
|
||||
Fn<void()> close)
|
||||
: _userDataPath(userDataPath)
|
||||
, _send(std::move(send))
|
||||
, _sendData(std::move(sendData))
|
||||
, _close(std::move(close))
|
||||
, _widget(std::make_unique<SeparatePanel>()) {
|
||||
_widget->setInnerSize(st::paymentsPanelSize);
|
||||
_widget->setWindowFlag(Qt::WindowStaysOnTopHint, false);
|
||||
|
||||
_widget->closeRequests(
|
||||
) | rpl::start_with_next(close, _widget->lifetime());
|
||||
) | rpl::start_with_next(_close, _widget->lifetime());
|
||||
|
||||
_widget->closeEvents(
|
||||
) | rpl::start_with_next(close, _widget->lifetime());
|
||||
) | rpl::start_with_next(_close, _widget->lifetime());
|
||||
|
||||
setTitle(rpl::single(u"Title"_q));
|
||||
}
|
||||
|
@ -293,11 +296,17 @@ bool Panel::createWebview() {
|
|||
"Not an array received in buy_callback arguments."));
|
||||
return;
|
||||
}
|
||||
const auto command = message.array().at(0).toString();
|
||||
const auto list = message.array();
|
||||
const auto command = list.at(0).toString();
|
||||
if (command == "webview_close") {
|
||||
_close();
|
||||
} else if (command == "webview_send_result_message") {
|
||||
_send();
|
||||
} else if (command == "webview_data_send") {
|
||||
//const auto tmp = list.at(1).toObject()["data"].toString().toUtf8();
|
||||
const auto send = [send = _sendData, message] {
|
||||
send(message.toJson(QJsonDocument::Compact));
|
||||
};
|
||||
_close();
|
||||
send();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -428,7 +437,7 @@ rpl::lifetime &Panel::lifetime() {
|
|||
std::unique_ptr<Panel> Show(Args &&args) {
|
||||
auto result = std::make_unique<Panel>(
|
||||
args.userDataPath,
|
||||
std::move(args.send),
|
||||
std::move(args.sendData),
|
||||
std::move(args.close));
|
||||
result->showWebview(args.url, rpl::single(u"smth"_q));
|
||||
return result;
|
||||
|
|
|
@ -23,7 +23,10 @@ namespace Ui::BotWebView {
|
|||
|
||||
class Panel final {
|
||||
public:
|
||||
Panel(const QString &userDataPath, Fn<void()> send, Fn<void()> close);
|
||||
Panel(
|
||||
const QString &userDataPath,
|
||||
Fn<void(QByteArray)> sendData,
|
||||
Fn<void()> close);
|
||||
~Panel();
|
||||
|
||||
void requestActivate();
|
||||
|
@ -56,7 +59,7 @@ private:
|
|||
void setupProgressGeometry();
|
||||
|
||||
QString _userDataPath;
|
||||
Fn<void()> _send;
|
||||
Fn<void(QByteArray)> _sendData;
|
||||
Fn<void()> _close;
|
||||
std::unique_ptr<SeparatePanel> _widget;
|
||||
std::unique_ptr<WebviewWithLifetime> _webview;
|
||||
|
@ -69,8 +72,9 @@ private:
|
|||
struct Args {
|
||||
QString url;
|
||||
QString userDataPath;
|
||||
Fn<void()> send;
|
||||
Fn<void(QByteArray)> sendData;
|
||||
Fn<void()> close;
|
||||
bool simple = false;
|
||||
};
|
||||
[[nodiscard]] std::unique_ptr<Panel> Show(Args &&args);
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/core_settings.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/random.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/text/format_values.h" // Ui::FormatPhone.
|
||||
|
@ -61,7 +62,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/toasts/common_toasts.h"
|
||||
#include "calls/calls_instance.h" // Core::App().calls().inCall().
|
||||
#include "calls/group/calls_group_call.h"
|
||||
#include "inline_bots/inline_bot_result.h"
|
||||
#include "ui/boxes/calendar_box.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "mainwidget.h"
|
||||
|
@ -430,24 +430,29 @@ void SessionNavigation::resolveAttachWebview(
|
|||
void SessionNavigation::requestAttachWebview(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<UserData*> bot,
|
||||
const QByteArray &url) {
|
||||
const WebViewButton &button) {
|
||||
using Flag = MTPmessages_RequestWebView::Flag;
|
||||
_api.request(MTPmessages_RequestWebView(
|
||||
MTP_flags(url.isEmpty() ? Flag(0) : Flag::f_url),
|
||||
MTP_flags(button.url.isEmpty() ? Flag(0) : Flag::f_url),
|
||||
peer->input,
|
||||
bot->inputUser,
|
||||
MTP_bytes(url),
|
||||
MTPDataJSON() // theme_params
|
||||
MTP_bytes(button.url),
|
||||
MTPDataJSON(), // theme_params
|
||||
MTPint() // reply_to_msg_id
|
||||
)).done([=](const MTPWebViewResult &result) {
|
||||
result.match([&](const MTPDwebViewResultUrl &data) {
|
||||
const auto url = qs(data.vurl());
|
||||
showAttachWebview(peer, bot, data.vquery_id().v, url);
|
||||
showAttachWebview(
|
||||
peer,
|
||||
bot,
|
||||
data.vquery_id().v,
|
||||
qs(data.vurl()),
|
||||
button.text);
|
||||
}, [&](const MTPDwebViewResultConfirmationRequired &data) {
|
||||
session().data().processUsers(data.vusers());
|
||||
const auto &received = data.vbot();
|
||||
if (const auto bot = ParseAttachBot(&session(), received)) {
|
||||
requestAddToMenu(bot, [=] {
|
||||
requestAttachWebview(peer, bot);
|
||||
requestAttachWebview(peer, bot, button);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -456,40 +461,53 @@ void SessionNavigation::requestAttachWebview(
|
|||
}).send();
|
||||
}
|
||||
|
||||
void SessionNavigation::requestAttachSimpleWebview(
|
||||
not_null<UserData*> bot,
|
||||
const QByteArray &url) {
|
||||
using Flag = MTPmessages_RequestSimpleWebView::Flag;
|
||||
_api.request(MTPmessages_RequestSimpleWebView(
|
||||
MTP_flags(0),
|
||||
bot->inputUser,
|
||||
MTP_bytes(url),
|
||||
MTPDataJSON()
|
||||
)).done([=](const MTPSimpleWebViewResult &result) {
|
||||
result.match([&](const MTPDsimpleWebViewResultUrl &data) {
|
||||
const auto queryId = uint64();
|
||||
showAttachWebview(bot, bot, queryId, qs(data.vurl()));
|
||||
});
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
int a = error.code();
|
||||
}).send();
|
||||
}
|
||||
|
||||
void SessionNavigation::showAttachWebview(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<UserData*> bot,
|
||||
uint64 queryId,
|
||||
const QString &url) {
|
||||
const QString &url,
|
||||
const QString &buttonText) {
|
||||
const auto close = crl::guard(this, [=] {
|
||||
_botWebView = nullptr;
|
||||
});
|
||||
const auto send = crl::guard(this, [=] {
|
||||
_api.request(MTPmessages_GetWebViewResult(
|
||||
peer->input,
|
||||
const auto sendData = crl::guard(this, [=](QByteArray data) {
|
||||
if (peer != bot || !queryId) {
|
||||
return;
|
||||
}
|
||||
const auto randomId = base::RandomValue<uint64>();
|
||||
const auto api = &session().api();
|
||||
api->request(MTPmessages_SendWebViewData(
|
||||
bot->inputUser,
|
||||
MTP_long(queryId)
|
||||
)).done([=](const MTPmessages_WebViewResult &result) {
|
||||
result.match([&](const MTPDmessages_webViewResult &data) {
|
||||
session().data().processUsers(data.vusers());
|
||||
auto result = InlineBots::Result::Create(
|
||||
&session(),
|
||||
queryId,
|
||||
data.vresult());
|
||||
_inlineResultConfirmed.fire({
|
||||
.result = result.get(),
|
||||
.bot = bot,
|
||||
.recipientOverride = peer,
|
||||
//.options =
|
||||
});
|
||||
close();
|
||||
});
|
||||
MTP_long(randomId),
|
||||
MTP_string(buttonText),
|
||||
MTP_bytes(data)
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
api->applyUpdates(result);
|
||||
}).send();
|
||||
});
|
||||
_botWebView = Ui::BotWebView::Show({
|
||||
.url = url,
|
||||
.userDataPath = session().domain().local().webviewDataPath(),
|
||||
.send = send,
|
||||
.sendData = sendData,
|
||||
.close = close,
|
||||
});
|
||||
}
|
||||
|
@ -521,11 +539,6 @@ void SessionNavigation::toggleInMenu(
|
|||
}).send();
|
||||
}
|
||||
|
||||
auto SessionNavigation::inlineResultConfirmed() const
|
||||
-> rpl::producer<InlineBots::ResultSelected> {
|
||||
return _inlineResultConfirmed.events();
|
||||
}
|
||||
|
||||
void SessionNavigation::showRepliesForMessage(
|
||||
not_null<History*> history,
|
||||
MsgId rootId,
|
||||
|
|
|
@ -65,10 +65,6 @@ namespace Ui::BotWebView {
|
|||
class Panel;
|
||||
} // namespace Ui::BotWebView
|
||||
|
||||
namespace InlineBots {
|
||||
struct ResultSelected;
|
||||
} // namespace InlineBots
|
||||
|
||||
namespace Data {
|
||||
struct CloudTheme;
|
||||
enum class CloudThemeType;
|
||||
|
@ -205,15 +201,21 @@ public:
|
|||
};
|
||||
void showPeerByLink(const PeerByLinkInfo &info);
|
||||
|
||||
struct WebViewButton {
|
||||
QString text;
|
||||
QByteArray url;
|
||||
bool simple = false;
|
||||
};
|
||||
void resolveAttachWebview(
|
||||
not_null<PeerData*> peer,
|
||||
const QString &botUsername);
|
||||
void requestAttachWebview(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<UserData*> bot,
|
||||
const QByteArray &url = QByteArray());
|
||||
[[nodiscard]] auto inlineResultConfirmed() const
|
||||
-> rpl::producer<InlineBots::ResultSelected>;
|
||||
const WebViewButton &button = WebViewButton());
|
||||
void requestAttachSimpleWebview(
|
||||
not_null<UserData*> bot,
|
||||
const QByteArray &url);
|
||||
|
||||
void showRepliesForMessage(
|
||||
not_null<History*> history,
|
||||
|
@ -287,7 +289,8 @@ private:
|
|||
not_null<PeerData*> peer,
|
||||
not_null<UserData*> bot,
|
||||
uint64 queryId,
|
||||
const QString &url);
|
||||
const QString &url,
|
||||
const QString &buttonText = QString());
|
||||
|
||||
void toggleInMenu(
|
||||
not_null<UserData*> bot,
|
||||
|
@ -305,7 +308,6 @@ private:
|
|||
mtpRequestId _showingRepliesRequestId = 0;
|
||||
|
||||
std::unique_ptr<Ui::BotWebView::Panel> _botWebView;
|
||||
rpl::event_stream<InlineBots::ResultSelected> _inlineResultConfirmed;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 45faed44e7f4d11fec79b7a70e4a35dc91ef3fdb
|
||||
Subproject commit 0d234b5aabf43d598e0cb0867566ee570d9e2755
|
Loading…
Add table
Reference in a new issue