Skip to content

Commit 217ce78

Browse files
dallo28claude
andcommitted
Hide Copy in text selection when Disable Sharing is on in private chats
ChatActivity's text-selection canCopy() only honoured the peer-level no-forwards flag for groups/channels (dialogId < 0). The private-chat "Disable Sharing" setting lives on UserFull (noforwards_my_enabled / noforwards_peer_enabled), so long-pressing a message in such a chat still offered Copy and Select All for the selected text. Use ChatActivity.isPeerNoForwards(), which covers both chats and users and is already used by the message context menu, limited to cloud chats so secret chats behave exactly as before. Also guard TextSelectionHelper.copyText() with canCopy() as a defensive check. Fixes https://bugs.telegram.org/c/66665 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f32ffee commit 217ce78

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ public void onGetContentRect(ActionMode mode, View view, Rect outRect) {
17311731
}
17321732

17331733
private void copyText() {
1734-
if (!isInSelectionMode()) {
1734+
if (!isInSelectionMode() || !canCopy()) {
17351735
return;
17361736
}
17371737
if (!onCopyOverride()) {

‎TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3557,7 +3557,7 @@ protected boolean canCopy() {
35573557
return true;
35583558
}
35593559
return chatActivity == null || !(
3560-
chatActivity.getDialogId() < 0 && chatActivity.getMessagesController().isPeerNoForwards(chatActivity.getDialogId()) ||
3560+
!DialogObject.isEncryptedDialog(chatActivity.getDialogId()) && chatActivity.isPeerNoForwards() ||
35613561
selectedView != null && selectedView.getMessageObject() != null && (selectedView.getMessageObject().messageOwner != null && selectedView.getMessageObject().messageOwner.noforwards)
35623562
);
35633563
}

0 commit comments

Comments
 (0)