Skip to content

Commit

Permalink
Prevent various operations on blocked users from conversation.
Browse files Browse the repository at this point in the history
Fix #10973
Closes #11979
  • Loading branch information
Sgn-32 authored and greyson-signal committed Jul 5, 2022
1 parent f8d4598 commit f3873c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Expand Up @@ -420,7 +420,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
enabled = it.canEditGroupAttributes && !state.recipient.isBlocked
}

if (!state.recipient.isReleaseNotes) {
if (!state.recipient.isReleaseNotes && !state.recipient.isBlocked) {
clickPref(
title = DSLSettingsText.from(R.string.ConversationSettingsFragment__disappearing_messages),
summary = summary,
Expand Down Expand Up @@ -557,15 +557,17 @@ class ConversationSettingsFragment : DSLSettingsFragment(
)
)

customPref(
LargeIconClickPreference.Model(
title = DSLSettingsText.from(R.string.ConversationSettingsFragment__add_to_a_group),
icon = DSLSettingsIcon.from(R.drawable.add_to_a_group, NO_TINT),
onClick = {
viewModel.onAddToGroup()
}
if (!state.recipient.isBlocked) {
customPref(
LargeIconClickPreference.Model(
title = DSLSettingsText.from(R.string.ConversationSettingsFragment__add_to_a_group),
icon = DSLSettingsIcon.from(R.drawable.add_to_a_group, NO_TINT),
onClick = {
viewModel.onAddToGroup()
}
)
)
)
}

for (group in recipientSettingsState.groupsInCommon) {
customPref(
Expand Down
Expand Up @@ -152,7 +152,7 @@ sealed class ConversationSettingsViewModel(
canModifyBlockedState = !recipient.isSelf && RecipientUtil.isBlockable(recipient),
specificSettingsState = state.requireRecipientSettingsState().copy(
contactLinkState = when {
recipient.isSelf || recipient.isReleaseNotes -> ContactLinkState.NONE
recipient.isSelf || recipient.isReleaseNotes || recipient.isBlocked -> ContactLinkState.NONE
recipient.isSystemContact -> ContactLinkState.OPEN
else -> ContactLinkState.ADD
}
Expand Down
Expand Up @@ -1002,6 +1002,10 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

inflater.inflate(R.menu.conversation, menu);

if (isInMessageRequest() && !recipient.get().isBlocked()) {
hideMenuItem(menu, R.id.menu_conversation_settings);
}

if (isSingleConversation() && !isSecureText && !recipient.get().isReleaseNotes()) {
inflater.inflate(R.menu.conversation_insecure, menu);
}
Expand Down Expand Up @@ -1309,7 +1313,7 @@ private void handleConversationSettings() {
return;
}

if (isInMessageRequest()) return;
if (isInMessageRequest() && !recipient.get().isBlocked()) return;

Intent intent = ConversationSettingsActivity.forRecipient(requireContext(), recipient.getId());
Bundle bundle = ConversationSettingsActivity.createTransitionBundle(requireActivity(), titleView.findViewById(R.id.contact_photo_image), toolbar);
Expand Down

0 comments on commit f3873c8

Please sign in to comment.