2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Update API scheme on layer 140.

Handle attach argument in resolve username links.
This commit is contained in:
John Preston
2022-03-24 17:41:59 +04:00
parent cdde9f8841
commit 841da9dde8
9 changed files with 73 additions and 1 deletions

View File

@@ -382,6 +382,7 @@ void SessionNavigation::showPeerByLinkResolved(
// Show specific posts only in channels / supergroups.
msgId = ShowAtUnreadMsgId;
}
const auto attachBotUsername = info.attachBotUsername;
if (user && user->isBot()) {
user->botInfo->startToken = info.startToken;
user->session().changes().peerUpdated(
@@ -390,10 +391,47 @@ void SessionNavigation::showPeerByLinkResolved(
}
crl::on_main(this, [=] {
showPeerHistory(peer->id, params, msgId);
showAttachWebview(peer, attachBotUsername);
});
}
}
void SessionNavigation::showAttachWebview(
not_null<PeerData*> peer,
const QString &botUsername) {
if (!peer->isUser() || botUsername.isEmpty()) {
return;
}
resolveUsername(botUsername, [=](not_null<PeerData*> bot) {
const auto user = bot->asUser();
if (!user || !user->isBot() || !user->botInfo->supportsAttachMenu) {
Ui::ShowMultilineToast({
// #TODO webview lang
.text = { u"This bot isn't supported in the attach menu."_q }
});
return;
}
// #TODO webview cancel request in destructor
session().api().request(MTPmessages_RequestWebView(
MTP_flags(0),
peer->input,
user->inputUser,
MTPstring(), // start_param
MTPDataJSON() // theme_params
)).done([=](const MTPWebViewResult &result) {
result.match([&](const MTPDwebViewResultUrl &data) {
int b = 0;
}, [&](const MTPDwebViewResultConfirmationRequired &data) {
session().data().processUsers(data.vusers());
int a = 0;
});
}).fail([=](const MTP::Error &error) {
int a = error.code();
}).send();
});
}
void SessionNavigation::showRepliesForMessage(
not_null<History*> history,
MsgId rootId,

View File

@@ -190,10 +190,14 @@ public:
BotStartType startType = BotStartType::None;
QString startToken;
ChatAdminRights startAdminRights;
QString attachBotUsername;
std::optional<QString> voicechatHash;
FullMsgId clickFromMessageId;
};
void showPeerByLink(const PeerByLinkInfo &info);
void showAttachWebview(
not_null<PeerData*> peer,
const QString &botUsername);
void showRepliesForMessage(
not_null<History*> history,