Skip to content

Commit

Permalink
Allow saving/copying restricted messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jul 24, 2024
1 parent 48f0065 commit 924357e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5728,7 +5728,10 @@ public boolean isChatNoForwards(TLRPC.Chat chat) {
}

public boolean isChatNoForwards(long chatId) {
/*
return isChatNoForwards(getChat(chatId));
*/
return false;
}

public TLRPC.User getUser(Long id) {
Expand Down
36 changes: 18 additions & 18 deletions TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -47813,7 +47813,7 @@ public static abstract class Chat extends TLObject {
public boolean call_not_empty;
public boolean fake;
public boolean gigagroup;
public boolean noforwards;
public boolean noforwards = false;
public boolean forum;
public ArrayList<TL_restrictionReason> restriction_reason = new ArrayList<>();
public TL_channelAdminRights_layer92 admin_rights_layer92;
Expand Down Expand Up @@ -48050,7 +48050,7 @@ public void readParams(AbstractSerializedData stream, boolean exception, boolean
deactivated = (flags & 32) != 0;
call_active = (flags & 8388608) != 0;
call_not_empty = (flags & 16777216) != 0;
noforwards = (flags & 33554432) != 0;
/* noforwards = (flags & 33554432) != 0; */
id = stream.readInt64(exception);
title = stream.readString(exception);
photo = ChatPhoto.TLdeserialize(stream, stream.readInt32(exception), exception, allowStrippedThumb);
Expand Down Expand Up @@ -48330,7 +48330,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
call_not_empty = (flags & 16777216) != 0;
fake = (flags & 33554432) != 0;
gigagroup = (flags & 67108864) != 0;
noforwards = (flags & 134217728) != 0;
/* noforwards = (flags & 134217728) != 0; */
join_to_send = (flags & 268435456) != 0;
join_request = (flags & 536870912) != 0;
forum = (flags & 1073741824) != 0;
Expand Down Expand Up @@ -48503,7 +48503,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
call_not_empty = (flags & 16777216) != 0;
fake = (flags & 33554432) != 0;
gigagroup = (flags & 67108864) != 0;
noforwards = (flags & 134217728) != 0;
/* noforwards = (flags & 134217728) != 0; */
join_to_send = (flags & 268435456) != 0;
join_request = (flags & 536870912) != 0;
forum = (flags & 1073741824) != 0;
Expand Down Expand Up @@ -48682,7 +48682,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
call_not_empty = (flags & 16777216) != 0;
fake = (flags & 33554432) != 0;
gigagroup = (flags & 67108864) != 0;
noforwards = (flags & 134217728) != 0;
/* noforwards = (flags & 134217728) != 0; */
join_to_send = (flags & 268435456) != 0;
join_request = (flags & 536870912) != 0;
forum = (flags & 1073741824) != 0;
Expand Down Expand Up @@ -48867,7 +48867,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
call_not_empty = (flags & 16777216) != 0;
fake = (flags & 33554432) != 0;
gigagroup = (flags & 67108864) != 0;
noforwards = (flags & 134217728) != 0;
/* noforwards = (flags & 134217728) != 0; */
join_to_send = (flags & 268435456) != 0;
join_request = (flags & 536870912) != 0;
forum = (flags & 1073741824) != 0;
Expand Down Expand Up @@ -49034,7 +49034,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
call_not_empty = (flags & 16777216) != 0;
fake = (flags & 33554432) != 0;
gigagroup = (flags & 67108864) != 0;
noforwards = (flags & 134217728) != 0;
/* noforwards = (flags & 134217728) != 0; */
join_to_send = (flags & 268435456) != 0;
join_request = (flags & 536870912) != 0;
forum = (flags & 1073741824) != 0;
Expand Down Expand Up @@ -49211,7 +49211,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
call_not_empty = (flags & 16777216) != 0;
fake = (flags & 33554432) != 0;
gigagroup = (flags & 67108864) != 0;
noforwards = (flags & 134217728) != 0;
/* noforwards = (flags & 134217728) != 0; */
join_to_send = (flags & 268435456) != 0;
join_request = (flags & 536870912) != 0;
forum = (flags & 1073741824) != 0;
Expand Down Expand Up @@ -49385,7 +49385,7 @@ public void readParams(AbstractSerializedData stream, boolean exception, boolean
call_not_empty = (flags & 16777216) != 0;
fake = (flags & 33554432) != 0;
gigagroup = (flags & 67108864) != 0;
noforwards = (flags & 134217728) != 0;
/* noforwards = (flags & 134217728) != 0; */
join_to_send = (flags & 268435456) != 0;
join_request = (flags & 536870912) != 0;
forum = (flags & 1073741824) != 0;
Expand Down Expand Up @@ -49539,7 +49539,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
call_not_empty = (flags & 16777216) != 0;
fake = (flags & 33554432) != 0;
gigagroup = (flags & 67108864) != 0;
noforwards = (flags & 134217728) != 0;
/* noforwards = (flags & 134217728) != 0; */
join_to_send = (flags & 268435456) != 0;
join_request = (flags & 536870912) != 0;
forum = (flags & 1073741824) != 0;
Expand Down Expand Up @@ -68512,7 +68512,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
legacy = (flags & 524288) != 0;
edit_hide = (flags & 2097152) != 0;
pinned = (flags & 16777216) != 0;
noforwards = (flags & 67108864) != 0;
/* noforwards = (flags & 67108864) != 0; */
invert_media = (flags & 134217728) != 0;
flags2 = stream.readInt32(exception);
offline = (flags2 & 2) != 0;
Expand Down Expand Up @@ -68736,7 +68736,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
legacy = (flags & 524288) != 0;
edit_hide = (flags & 2097152) != 0;
pinned = (flags & 16777216) != 0;
noforwards = (flags & 67108864) != 0;
/* noforwards = (flags & 67108864) != 0; */
invert_media = (flags & 134217728) != 0;
flags2 = stream.readInt32(exception);
offline = (flags2 & 2) != 0;
Expand Down Expand Up @@ -68954,7 +68954,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
legacy = (flags & 524288) != 0;
edit_hide = (flags & 2097152) != 0;
pinned = (flags & 16777216) != 0;
noforwards = (flags & 67108864) != 0;
/* noforwards = (flags & 67108864) != 0; */
invert_media = (flags & 134217728) != 0;
flags2 = stream.readInt32(exception);
offline = (flags2 & 2) != 0;
Expand Down Expand Up @@ -69166,7 +69166,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
legacy = (flags & 524288) != 0;
edit_hide = (flags & 2097152) != 0;
pinned = (flags & 16777216) != 0;
noforwards = (flags & 67108864) != 0;
/* noforwards = (flags & 67108864) != 0; */
invert_media = (flags & 134217728) != 0;
id = stream.readInt32(exception);
if ((flags & 256) != 0) {
Expand Down Expand Up @@ -69368,7 +69368,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
legacy = (flags & 524288) != 0;
edit_hide = (flags & 2097152) != 0;
pinned = (flags & 16777216) != 0;
noforwards = (flags & 67108864) != 0;
/* noforwards = (flags & 67108864) != 0; */
invert_media = (flags & 134217728) != 0;
id = stream.readInt32(exception);
if ((flags & 256) != 0) {
Expand Down Expand Up @@ -69564,7 +69564,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
legacy = (flags & 524288) != 0;
edit_hide = (flags & 2097152) != 0;
pinned = (flags & 16777216) != 0;
noforwards = (flags & 67108864) != 0;
/* noforwards = (flags & 67108864) != 0; */
invert_media = (flags & 134217728) != 0;
id = stream.readInt32(exception);
if ((flags & 256) != 0) {
Expand Down Expand Up @@ -69754,7 +69754,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
legacy = (flags & 524288) != 0;
edit_hide = (flags & 2097152) != 0;
pinned = (flags & 16777216) != 0;
noforwards = (flags & 67108864) != 0;
/* noforwards = (flags & 67108864) != 0; */
invert_media = (flags & 134217728) != 0;
id = stream.readInt32(exception);
if ((flags & 256) != 0) {
Expand Down Expand Up @@ -69939,7 +69939,7 @@ public void readParams(AbstractSerializedData stream, boolean exception) {
legacy = (flags & 524288) != 0;
edit_hide = (flags & 2097152) != 0;
pinned = (flags & 16777216) != 0;
noforwards = (flags & 67108864) != 0;
/* noforwards = (flags & 67108864) != 0; */
id = stream.readInt32(exception);
if ((flags & 256) != 0) {
from_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception);
Expand Down
7 changes: 4 additions & 3 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3134,14 +3134,15 @@ protected boolean canShowQuote() {
);
}

/*
@Override
protected boolean canCopy() {
return chatActivity == null || !(
chatActivity.getDialogId() < 0 && chatActivity.getMessagesController().isChatNoForwards(-chatActivity.getDialogId()) ||
selectedView != null && selectedView.getMessageObject() != null && (selectedView.getMessageObject().messageOwner != null && selectedView.getMessageObject().messageOwner.noforwards)
);
}

*/
@Override
protected void onQuoteClick(MessageObject messageObject, int start, int end, CharSequence text) {
if (messageObject == null) {
Expand Down Expand Up @@ -9319,7 +9320,7 @@ private void createActionMode() {
actionModeViews.add(actionMode.addItemWithWidth(delete, R.drawable.msg_delete, AndroidUtilities.dp(54), LocaleController.getString(R.string.Delete)));
}
actionMode.setItemVisibility(edit, canEditMessagesCount == 1 && selectedMessagesIds[0].size() + selectedMessagesIds[1].size() == 1 ? View.VISIBLE : View.GONE);
actionMode.setItemVisibility(copy, !getMessagesController().isChatNoForwards(currentChat) && selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE);
actionMode.setItemVisibility(copy, /* !getMessagesController().isChatNoForwards(currentChat) && selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE */ View.VISIBLE);
actionMode.setItemVisibility(star, selectedMessagesCanStarIds[0].size() + selectedMessagesCanStarIds[1].size() != 0 ? View.VISIBLE : View.GONE);
actionMode.setItemVisibility(delete, cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE);
actionMode.setItemVisibility(tag_message, getUserConfig().isPremium() ? View.VISIBLE : View.GONE);
Expand Down Expand Up @@ -32617,7 +32618,7 @@ private void openClickableLink(CharacterStyle url, String str, boolean longPress
builder.setTitleMultipleLines(true);
}
final int finalTimestamp = timestamp;
boolean noforwards = getMessagesController().isChatNoForwards(currentChat) || (messageObject != null && messageObject.messageOwner != null && messageObject.messageOwner.noforwards);
boolean noforwards = false; /* getMessagesController().isChatNoForwards(currentChat) || (messageObject != null && messageObject.messageOwner != null && messageObject.messageOwner.noforwards); */
builder.setItems(noforwards ? new CharSequence[] {LocaleController.getString("Open", R.string.Open)} : new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy)}, (dialog, which) -> {
if (which == 0) {
if (str.startsWith("video?")) {
Expand Down

0 comments on commit 924357e

Please sign in to comment.