-
Notifications
You must be signed in to change notification settings - Fork 11
/
0002-Disable-saving-restrictions.patch
291 lines (262 loc) · 9.52 KB
/
0002-Disable-saving-restrictions.patch
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp
index 915b12f..78c88e8 100644
--- a/Telegram/SourceFiles/core/click_handler_types.cpp
+++ b/Telegram/SourceFiles/core/click_handler_types.cpp
@@ -366,15 +366,6 @@ void MonospaceClickHandler::onClick(ClickContext context) const {
if (const auto controller = my.sessionWindow.get()) {
auto &data = controller->session().data();
const auto item = data.message(my.itemId);
- const auto hasCopyRestriction = item
- && (!item->history()->peer->allowsForwarding()
- || item->forbidsForward());
- if (hasCopyRestriction) {
- controller->showToast(item->history()->peer->isBroadcast()
- ? tr::lng_error_nocopy_channel(tr::now)
- : tr::lng_error_nocopy_group(tr::now));
- return;
- }
controller->showToast(tr::lng_text_copied(tr::now));
}
TextUtilities::SetClipboardText(TextForMimeData::Simple(_text.trimmed()));
diff --git a/Telegram/SourceFiles/data/data_story.cpp b/Telegram/SourceFiles/data/data_story.cpp
index 38ea28a..53ccc5a 100644
--- a/Telegram/SourceFiles/data/data_story.cpp
+++ b/Telegram/SourceFiles/data/data_story.cpp
@@ -458,12 +458,11 @@ bool Story::out() const {
}
bool Story::canDownloadIfPremium() const {
- return !forbidsForward() || _peer->isSelf();
+ return true;
}
bool Story::canDownloadChecked() const {
- return _peer->isSelf()
- || (canDownloadIfPremium() && _peer->session().premium());
+ return true;
}
bool Story::canShare() const {
diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp
index 7838dda..cd77292 100644
--- a/Telegram/SourceFiles/history/history_inner_widget.cpp
+++ b/Telegram/SourceFiles/history/history_inner_widget.cpp
@@ -558,14 +558,7 @@ void HistoryInner::setupSharingDisallowed() {
}
bool HistoryInner::hasSelectRestriction() const {
- if (!_sharingDisallowed.current()) {
- return false;
- } else if (const auto chat = _peer->asChat()) {
- return !chat->canDeleteMessages();
- } else if (const auto channel = _peer->asChannel()) {
- return !channel->canDeleteMessages();
- }
- return true;
+ return false;
}
void HistoryInner::messagesReceived(
@@ -2847,52 +2840,27 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
}
bool HistoryInner::hasCopyRestriction(HistoryItem *item) const {
- return !_peer->allowsForwarding() || (item && item->forbidsForward());
+ return false;
}
bool HistoryInner::hasCopyMediaRestriction(
not_null<HistoryItem*> item) const {
- return hasCopyRestriction(item) || item->forbidsSaving();
+ return false;
}
bool HistoryInner::showCopyRestriction(HistoryItem *item) {
- if (!hasCopyRestriction(item)) {
- return false;
- }
- _controller->showToast(_peer->isBroadcast()
- ? tr::lng_error_nocopy_channel(tr::now)
- : tr::lng_error_nocopy_group(tr::now));
- return true;
+ return false;
}
bool HistoryInner::showCopyMediaRestriction(not_null<HistoryItem*> item) {
- if (!hasCopyMediaRestriction(item)) {
- return false;
- }
- _controller->showToast(_peer->isBroadcast()
- ? tr::lng_error_nocopy_channel(tr::now)
- : tr::lng_error_nocopy_group(tr::now));
- return true;
+ return false;
}
bool HistoryInner::hasCopyRestrictionForSelected() const {
- if (hasCopyRestriction()) {
- return true;
- }
- for (const auto &[item, selection] : _selected) {
- if (item && item->forbidsForward()) {
- return true;
- }
- }
return false;
}
bool HistoryInner::showCopyRestrictionForSelected() {
- for (const auto &[item, selection] : _selected) {
- if (showCopyRestriction(item)) {
- return true;
- }
- }
return false;
}
diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp
index d2386e7..5f61381 100644
--- a/Telegram/SourceFiles/history/history_item.cpp
+++ b/Telegram/SourceFiles/history/history_item.cpp
@@ -2244,11 +2244,6 @@ bool HistoryItem::forbidsForward() const {
}
bool HistoryItem::forbidsSaving() const {
- if (forbidsForward()) {
- return true;
- } else if (const auto invoice = _media ? _media->invoice() : nullptr) {
- return HasExtendedMedia(*invoice);
- }
return false;
}
diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
index 4155adf..5ea96fa 100644
--- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
+++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
@@ -1515,73 +1515,31 @@ bool ListWidget::isEmpty() const {
}
bool ListWidget::hasCopyRestriction(HistoryItem *item) const {
- return _delegate->listCopyRestrictionType(item)
- != CopyRestrictionType::None;
+ return false;
}
bool ListWidget::hasCopyMediaRestriction(not_null<HistoryItem*> item) const {
- return _delegate->listCopyMediaRestrictionType(item)
- != CopyRestrictionType::None;
+ return false;
}
bool ListWidget::showCopyRestriction(HistoryItem *item) {
- const auto type = _delegate->listCopyRestrictionType(item);
- if (type == CopyRestrictionType::None) {
- return false;
- }
- _delegate->listUiShow()->showToast((type == CopyRestrictionType::Channel)
- ? tr::lng_error_nocopy_channel(tr::now)
- : tr::lng_error_nocopy_group(tr::now));
- return true;
+ return false;
}
bool ListWidget::showCopyMediaRestriction(not_null<HistoryItem*> item) {
- const auto type = _delegate->listCopyMediaRestrictionType(item);
- if (type == CopyRestrictionType::None) {
- return false;
- }
- _delegate->listUiShow()->showToast((type == CopyRestrictionType::Channel)
- ? tr::lng_error_nocopy_channel(tr::now)
- : tr::lng_error_nocopy_group(tr::now));
- return true;
+ return false;
}
bool ListWidget::hasCopyRestrictionForSelected() const {
- if (hasCopyRestriction()) {
- return true;
- }
- if (_selected.empty()) {
- if (_selectedTextItem && _selectedTextItem->forbidsForward()) {
- return true;
- }
- }
- for (const auto &[itemId, selection] : _selected) {
- if (const auto item = session().data().message(itemId)) {
- if (item->forbidsForward()) {
- return true;
- }
- }
- }
return false;
}
bool ListWidget::showCopyRestrictionForSelected() {
- if (_selected.empty()) {
- if (_selectedTextItem && showCopyRestriction(_selectedTextItem)) {
- return true;
- }
- }
- for (const auto &[itemId, selection] : _selected) {
- if (showCopyRestriction(session().data().message(itemId))) {
- return true;
- }
- }
return false;
}
bool ListWidget::hasSelectRestriction() const {
- return _delegate->listSelectRestrictionType()
- != CopyRestrictionType::None;
+ return false;
}
Element *ListWidget::lookupItemByY(int y) const {
diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
index 92bd218..57c5150 100644
--- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
+++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
@@ -1240,15 +1240,14 @@ void TopBarWidget::updateMembersShowArea() {
}
bool TopBarWidget::showSelectedState() const {
- return (_selectedCount > 0)
- && (_canDelete || _canForward || _canSendNow);
+ return (_selectedCount > 0);
}
void TopBarWidget::showSelected(SelectedState state) {
- auto canDelete = (state.count > 0 && state.count == state.canDeleteCount);
- auto canForward = (state.count > 0 && state.count == state.canForwardCount);
- auto canSendNow = (state.count > 0 && state.count == state.canSendNowCount);
- auto count = (!canDelete && !canForward && !canSendNow) ? 0 : state.count;
+ auto canDelete = (state.count > 0);
+ auto canForward = (state.count > 0);
+ auto canSendNow = (state.count > 0);
+ auto count = state.count;
if (_selectedCount == count
&& _canDelete == canDelete
&& _canForward == canForward
diff --git a/Telegram/SourceFiles/info/media/info_media_provider.cpp b/Telegram/SourceFiles/info/media/info_media_provider.cpp
index 2fc6973..e3101f3 100644
--- a/Telegram/SourceFiles/info/media/info_media_provider.cpp
+++ b/Telegram/SourceFiles/info/media/info_media_provider.cpp
@@ -88,13 +88,6 @@ Type Provider::type() {
}
bool Provider::hasSelectRestriction() {
- if (_peer->allowsForwarding()) {
- return false;
- } else if (const auto chat = _peer->asChat()) {
- return !chat->canDeleteMessages();
- } else if (const auto channel = _peer->asChannel()) {
- return !channel->canDeleteMessages();
- }
return true;
}
diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
index c6a7e9c..8407567 100644
--- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
+++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
@@ -1033,26 +1033,11 @@ QSize OverlayWidget::flipSizeByRotation(QSize size) const {
}
bool OverlayWidget::hasCopyMediaRestriction(bool skipPremiumCheck) const {
- if (const auto story = _stories ? _stories->story() : nullptr) {
- return skipPremiumCheck
- ? !story->canDownloadIfPremium()
- : !story->canDownloadChecked();
- }
- return (_history && !_history->peer->allowsForwarding())
- || (_message && _message->forbidsSaving());
+ return false;
}
bool OverlayWidget::showCopyMediaRestriction(bool skipPRemiumCheck) {
- if (!hasCopyMediaRestriction(skipPRemiumCheck)) {
- return false;
- } else if (_stories) {
- uiShow()->showToast(tr::lng_error_nocopy_story(tr::now));
- } else if (_history) {
- uiShow()->showToast(_history->peer->isBroadcast()
- ? tr::lng_error_nocopy_channel(tr::now)
- : tr::lng_error_nocopy_group(tr::now));
- }
- return true;
+ return false;
}
bool OverlayWidget::videoShown() const {