Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add patches to disable some anti-features #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions 0001-Disable-sponsored-messages.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/Telegram/SourceFiles/data/data_sponsored_messages.cpp b/Telegram/SourceFiles/data/data_sponsored_messages.cpp
index 556bee6..dfeaea4 100644
--- a/Telegram/SourceFiles/data/data_sponsored_messages.cpp
+++ b/Telegram/SourceFiles/data/data_sponsored_messages.cpp
@@ -181,7 +181,7 @@ void SponsoredMessages::inject(
}

bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
- return history->peer->isChannel();
+ return false;
}

void SponsoredMessages::request(not_null<History*> history, Fn<void()> done) {
--
2.43.0
200 changes: 200 additions & 0 deletions 0002-Disable-saving-restrictions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp
index 36d1871..b95b263 100644
--- a/Telegram/SourceFiles/core/click_handler_types.cpp
+++ b/Telegram/SourceFiles/core/click_handler_types.cpp
@@ -330,9 +330,7 @@ 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());
+ const auto hasCopyRestriction = false;
if (hasCopyRestriction) {
controller->showToast(item->history()->peer->isBroadcast()
? tr::lng_error_nocopy_channel(tr::now)
diff --git a/Telegram/SourceFiles/data/data_story.cpp b/Telegram/SourceFiles/data/data_story.cpp
index 7631892..ddfe984 100644
--- a/Telegram/SourceFiles/data/data_story.cpp
+++ b/Telegram/SourceFiles/data/data_story.cpp
@@ -412,12 +412,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 56eeb49..4dac4e0 100644
--- a/Telegram/SourceFiles/history/history_inner_widget.cpp
+++ b/Telegram/SourceFiles/history/history_inner_widget.cpp
@@ -635,14 +635,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(
@@ -2755,12 +2748,12 @@ 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) {
diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp
index 876757e..c8144d3 100644
--- a/Telegram/SourceFiles/history/history_item.cpp
+++ b/Telegram/SourceFiles/history/history_item.cpp
@@ -2101,11 +2101,6 @@ bool HistoryItem::forbidsForward() const {
}

bool HistoryItem::forbidsSaving() const {
- if (forbidsForward()) {
- return true;
- } else if (const auto invoice = _media ? _media->invoice() : nullptr) {
- return (invoice->extendedMedia != nullptr);
- }
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 0833209..cda7951 100644
--- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
+++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
@@ -1433,13 +1433,11 @@ 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) {
@@ -1465,21 +1463,6 @@ bool ListWidget::showCopyMediaRestriction(not_null<HistoryItem*> item) {
}

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;
}

@@ -1498,8 +1481,7 @@ bool ListWidget::showCopyRestrictionForSelected() {
}

bool ListWidget::hasSelectRestriction() const {
- return _delegate->listSelectRestrictionType()
- != CopyRestrictionType::None;
+ return false;
}

auto ListWidget::findViewForPinnedTracking(int top) 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 c026ab9..0f982fb 100644
--- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
+++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
@@ -1164,15 +1164,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 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..2e830b7 100644
--- a/Telegram/SourceFiles/info/media/info_media_provider.cpp
+++ b/Telegram/SourceFiles/info/media/info_media_provider.cpp
@@ -88,14 +88,7 @@ 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;
+ return false;
}

rpl::producer<bool> Provider::hasSelectRestrictionChanges() {
diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
index 20e41ce..8e9c369 100644
--- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
+++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
@@ -1031,13 +1031,7 @@ 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) {
--
2.43.0
15 changes: 15 additions & 0 deletions 0003-Disable-invite-peeking-restrictions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp
index fecbe62..078b5d9 100644
--- a/Telegram/SourceFiles/data/data_channel.cpp
+++ b/Telegram/SourceFiles/data/data_channel.cpp
@@ -813,7 +813,7 @@ void ChannelData::clearInvitePeek() {
}

TimeId ChannelData::invitePeekExpires() const {
- return _invitePeek ? _invitePeek->expires : 0;
+ return 0;
}

QString ChannelData::invitePeekHash() const {
--
2.43.0
17 changes: 17 additions & 0 deletions 0004-Disable-accounts-limit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/Telegram/SourceFiles/main/main_domain.h b/Telegram/SourceFiles/main/main_domain.h
index 1a39e8e..bf08cfd 100644
--- a/Telegram/SourceFiles/main/main_domain.h
+++ b/Telegram/SourceFiles/main/main_domain.h
@@ -30,8 +30,8 @@ public:
std::unique_ptr<Account> account;
};

- static constexpr auto kMaxAccounts = 3;
- static constexpr auto kPremiumMaxAccounts = 6;
+ static constexpr auto kMaxAccounts = 255;
+ static constexpr auto kPremiumMaxAccounts = 255;

explicit Domain(const QString &dataName);
~Domain();
--
2.43.0
5 changes: 5 additions & 0 deletions telegram-desktop.spec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ URL: https://github.com/telegramdesktop/%{appname}
Summary: Telegram Desktop official messaging app
Source0: %{url}/releases/download/v%{version}/%{appname}-%{version}-full.tar.gz

Patch1: 0001-Disable-sponsored-messages.patch
Patch2: 0002-Disable-saving-restrictions.patch
Patch3: 0003-Disable-invite-peeking-restrictions.patch
Patch4: 0004-Disable-accounts-limit.patch

# Telegram Desktop require more than 8 GB of RAM on linking stage.
# Disabling all low-memory architectures.
ExclusiveArch: x86_64 aarch64
Expand Down