From f2f906fd3ef9207f783cf2539af846815b7695d2 Mon Sep 17 00:00:00 2001 From: jubb Date: Wed, 27 Oct 2021 17:26:44 +1100 Subject: [PATCH] refactor: closed groups delete for yourself and handle unsend request if it's from yourself or author now --- .../securesms/conversation/v2/DeleteOptionsBottomSheet.kt | 2 ++ .../messaging/sending_receiving/ReceivedMessageHandler.kt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/DeleteOptionsBottomSheet.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/DeleteOptionsBottomSheet.kt index ccf30b55b1..6272a9c224 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/DeleteOptionsBottomSheet.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/DeleteOptionsBottomSheet.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import com.google.android.material.bottomsheet.BottomSheetDialogFragment import dagger.hilt.android.AndroidEntryPoint import kotlinx.android.synthetic.main.fragment_delete_message_bottom_sheet.* @@ -57,6 +58,7 @@ class DeleteOptionsBottomSheet : BottomSheetDialogFragment(), View.OnClickListen deleteForEveryoneTextView.text = resources.getString(R.string.delete_message_for_me_and_recipient, contact) } + deleteForEveryoneTextView.isVisible = !recipient.isClosedGroupRecipient deleteForMeTextView.setOnClickListener(this) deleteForEveryoneTextView.setOnClickListener(this) cancelTextView.setOnClickListener(this) diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt index a99c268687..4f94df7cef 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/ReceivedMessageHandler.kt @@ -144,7 +144,8 @@ private fun handleConfigurationMessage(message: ConfigurationMessage) { } fun MessageReceiver.handleUnsendRequest(message: UnsendRequest) { - if (message.sender != message.author) { return } + val userPublicKey = MessagingModuleConfiguration.shared.storage.getUserPublicKey() + if (message.sender != message.author && (message.sender != userPublicKey && userPublicKey != null)) { return } val context = MessagingModuleConfiguration.shared.context val storage = MessagingModuleConfiguration.shared.storage val messageDataProvider = MessagingModuleConfiguration.shared.messageDataProvider