Repository navigation
Expand file tree
/
Copy path0025-feat-open-links-without-confirmation.patch
More file actions
127 lines (123 loc) · 5.85 KB
/
Copy path0025-feat-open-links-without-confirmation.patch
File metadata and controls
127 lines (123 loc) · 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: nitreojs <hello@starkow.dev>
Date: Sun, 27 Sep 2026 05:05:35 +0300
Subject: [PATCH] feat: open links without confirmation
---
Telegram/SourceFiles/core/click_handler_types.cpp | 4 +++-
.../history/view/media/history_view_poll.cpp | 4 +++-
Telegram/SourceFiles/settings/settings_tele.cpp | 1 +
Telegram/SourceFiles/tele/tele_options.cpp | 13 +++++++++++++
Telegram/SourceFiles/tele/tele_options.h | 2 ++
5 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp
index 162971ff04271ec7edc84be3802f25d05b6a3db6..45720cc88d3dee176a41390d7c92b7ce6340edd5 100644
--- a/Telegram/SourceFiles/core/click_handler_types.cpp
+++ b/Telegram/SourceFiles/core/click_handler_types.cpp
@@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "window/window_controller.h"
#include "window/window_session_controller.h"
+#include "tele/tele_options.h"
#include "window/window_session_controller_link_info.h"
#include "apiwrap.h"
#include "history/view/history_view_schedule_box.h"
@@ -290,7 +291,8 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) {
auto openContext = context;
const auto forceConfirmation = my.forceExternalUrlConfirmation
&& my.ignoreIv;
- const auto skipConfirmation = base::IsCtrlPressed();
+ const auto skipConfirmation = base::IsCtrlPressed()
+ || Tele::NoLinkWarning();
if (forceConfirmation) {
my.forceExternalUrlConfirmation = false;
openContext = QVariant::fromValue(my);
diff --git a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp
index 8af35b1f3b3e8462a7c3e3602de46972189daf3b..ef294ff6a271456d1f36d05affc81a8010059fdd 100644
--- a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp
+++ b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp
@@ -64,6 +64,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "apiwrap.h"
#include "api/api_polls.h"
+#include "tele/tele_options.h"
#include "window/window_session_controller.h"
#include "ui/layers/generic_box.h"
#include "ui/wrap/padding_wrap.h"
@@ -599,7 +600,8 @@ struct PollThumbnailData {
ClickHandlerContext>();
const auto controller = my.sessionWindow.get();
if (!controller
- || (&controller->session() != session)) {
+ || (&controller->session() != session)
+ || Tele::NoLinkWarning()) {
UrlClickHandler::Open(url);
return;
}
diff --git a/Telegram/SourceFiles/settings/settings_tele.cpp b/Telegram/SourceFiles/settings/settings_tele.cpp
index 616db2d1d3bd37e9af2d6164e667b623ee30a7bd..1ee22e0fe2fc86aae2f065a473b115e9405a6318 100644
--- a/Telegram/SourceFiles/settings/settings_tele.cpp
+++ b/Telegram/SourceFiles/settings/settings_tele.cpp
@@ -627,6 +627,7 @@ void TeleSection::setupContent() {
AddOptionToggle(content, controller(), ::Tele::kOptionBubbleBadges);
AddOptionToggle(content, controller(), ::Tele::kOptionHideCalls);
AddOptionToggle(content, controller(), ::Tele::kOptionHideSponsored);
+ AddOptionToggle(content, controller(), ::Tele::kOptionNoLinkWarning);
Ui::AddSkip(content);
Ui::AddDivider(content);
Ui::AddSkip(content);
diff --git a/Telegram/SourceFiles/tele/tele_options.cpp b/Telegram/SourceFiles/tele/tele_options.cpp
index 57fc16f29e79da0ece3dbb1ffaf745a3ee12a7c0..2be477232e33c4493a12a04affeb3062d2a66e10 100644
--- a/Telegram/SourceFiles/tele/tele_options.cpp
+++ b/Telegram/SourceFiles/tele/tele_options.cpp
@@ -13,6 +13,7 @@ const char kOptionBubbleBadges[] = "tele-bubble-badges";
const char kOptionHideCalls[] = "tele-hide-calls";
const char kOptionLowercase[] = "tele-lowercase";
const char kOptionHideSponsored[] = "tele-hide-sponsored";
+const char kOptionNoLinkWarning[] = "tele-no-link-warning";
const char kOptionShowGiftIds[] = "tele-show-gift-ids";
const char kOptionPeerIdsWithoutSpaces[] = "tele-peer-ids-without-spaces";
const char kOptionBotApiPeerIds[] = "tele-bot-api-peer-ids";
@@ -101,6 +102,14 @@ base::options::toggle HideSponsoredOption({
"in search and no proxy sponsor channel in the chat list.",
});
+base::options::toggle NoLinkWarningOption({
+ .id = kOptionNoLinkWarning,
+ .name = "Open links without confirmation",
+ .description = "Open links with custom text and poll option links "
+ "right away, without asking first. Bot login and permission "
+ "prompts still ask.",
+});
+
base::options::toggle ShowGiftIdsOption({
.id = kOptionShowGiftIds,
.name = "Show gift IDs",
@@ -253,6 +262,10 @@ rpl::producer<bool> HideSponsoredValue() {
});
}
+bool NoLinkWarning() {
+ return NoLinkWarningOption.value();
+}
+
bool ShowGiftIds() {
return ShowGiftIdsOption.value();
}
diff --git a/Telegram/SourceFiles/tele/tele_options.h b/Telegram/SourceFiles/tele/tele_options.h
index c5a9e2dbbade43a0b9a333a6adee84a57cc256fa..bf4c053f1b0a3db83c7c4aa8afe292a6bdc4e098 100644
--- a/Telegram/SourceFiles/tele/tele_options.h
+++ b/Telegram/SourceFiles/tele/tele_options.h
@@ -11,6 +11,7 @@ extern const char kOptionBubbleBadges[];
extern const char kOptionHideCalls[];
extern const char kOptionLowercase[];
extern const char kOptionHideSponsored[];
+extern const char kOptionNoLinkWarning[];
extern const char kOptionShowGiftIds[];
extern const char kOptionPeerIdsWithoutSpaces[];
extern const char kOptionBotApiPeerIds[];
@@ -36,6 +37,7 @@ extern const char kOptionTitleTemplate[];
[[nodiscard]] rpl::producer<> HideCallsChanges();
[[nodiscard]] bool HideSponsored();
[[nodiscard]] rpl::producer<bool> HideSponsoredValue();
+[[nodiscard]] bool NoLinkWarning();
[[nodiscard]] bool ShowGiftIds();
[[nodiscard]] bool PeerIdsWithoutSpaces();
[[nodiscard]] bool BotApiPeerIds();