From b84c876ba257f1070ddd385131bab897c59283d8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 18 Jun 2022 00:02:27 +0400 Subject: [PATCH] Fix opening links from bot inline reply markup. --- Telegram/SourceFiles/core/click_handler_types.cpp | 9 +++++++-- Telegram/SourceFiles/facades.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index caffdce7c..e754c328d 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item.h" #include "data/data_user.h" #include "data/data_session.h" +#include "window/window_controller.h" #include "window/window_session_controller.h" namespace { @@ -118,8 +119,12 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) { ? QString::fromUtf8(parsedUrl.toEncoded()) : ShowEncoded(displayed); const auto my = context.value(); - if (const auto controller = my.sessionWindow.get()) { - controller->show( + const auto controller = my.sessionWindow.get(); + const auto use = controller + ? &controller->window() + : Core::App().activeWindow(); + if (use) { + use->show( Ui::MakeConfirmBox({ .text = (tr::lng_open_this_link(tr::now) + qsl("\n\n") diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index ad40fd27a..dd33432c0 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -133,10 +133,13 @@ void activateBotCommand( skipConfirmation = true; } } + const auto context = QVariant::fromValue(ClickHandlerContext{ + .sessionWindow = sessionController.get(), + }); if (skipConfirmation) { - UrlClickHandler::Open(url); + UrlClickHandler::Open(url, context); } else { - HiddenUrlClickHandler::Open(url); + HiddenUrlClickHandler::Open(url, context); } } break;