fix: open group message requests were broken anyway
This commit is contained in:
parent
df53a87c12
commit
cbb6168e0b
|
@ -105,13 +105,12 @@ import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
import org.thoughtcrime.securesms.attachments.ScreenshotObserver
|
import org.thoughtcrime.securesms.attachments.ScreenshotObserver
|
||||||
import org.thoughtcrime.securesms.audio.AudioRecorder
|
import org.thoughtcrime.securesms.audio.AudioRecorder
|
||||||
import org.thoughtcrime.securesms.contacts.SelectContactsActivity.Companion.selectedContactsKey
|
import org.thoughtcrime.securesms.contacts.SelectContactsActivity.Companion.selectedContactsKey
|
||||||
import org.thoughtcrime.securesms.util.SimpleTextWatcher
|
|
||||||
import org.thoughtcrime.securesms.conversation.v2.ConversationReactionOverlay.OnActionSelectedListener
|
import org.thoughtcrime.securesms.conversation.v2.ConversationReactionOverlay.OnActionSelectedListener
|
||||||
import org.thoughtcrime.securesms.conversation.v2.ConversationReactionOverlay.OnReactionSelectedListener
|
import org.thoughtcrime.securesms.conversation.v2.ConversationReactionOverlay.OnReactionSelectedListener
|
||||||
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.MESSAGE_TIMESTAMP
|
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.MESSAGE_TIMESTAMP
|
||||||
|
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.ON_DELETE
|
||||||
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.ON_REPLY
|
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.ON_REPLY
|
||||||
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.ON_RESEND
|
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.ON_RESEND
|
||||||
import org.thoughtcrime.securesms.conversation.v2.MessageDetailActivity.Companion.ON_DELETE
|
|
||||||
import org.thoughtcrime.securesms.conversation.v2.dialogs.BlockedDialog
|
import org.thoughtcrime.securesms.conversation.v2.dialogs.BlockedDialog
|
||||||
import org.thoughtcrime.securesms.conversation.v2.dialogs.LinkPreviewDialog
|
import org.thoughtcrime.securesms.conversation.v2.dialogs.LinkPreviewDialog
|
||||||
import org.thoughtcrime.securesms.conversation.v2.dialogs.SendSeedDialog
|
import org.thoughtcrime.securesms.conversation.v2.dialogs.SendSeedDialog
|
||||||
|
@ -174,6 +173,7 @@ import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
||||||
import org.thoughtcrime.securesms.util.DateUtils
|
import org.thoughtcrime.securesms.util.DateUtils
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil
|
import org.thoughtcrime.securesms.util.MediaUtil
|
||||||
import org.thoughtcrime.securesms.util.SaveAttachmentTask
|
import org.thoughtcrime.securesms.util.SaveAttachmentTask
|
||||||
|
import org.thoughtcrime.securesms.util.SimpleTextWatcher
|
||||||
import org.thoughtcrime.securesms.util.isScrolledToBottom
|
import org.thoughtcrime.securesms.util.isScrolledToBottom
|
||||||
import org.thoughtcrime.securesms.util.push
|
import org.thoughtcrime.securesms.util.push
|
||||||
import org.thoughtcrime.securesms.util.toPx
|
import org.thoughtcrime.securesms.util.toPx
|
||||||
|
@ -240,11 +240,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||||
val address = if (sessionId.prefix == IdPrefix.BLINDED && openGroup != null) {
|
val address = if (sessionId.prefix == IdPrefix.BLINDED && openGroup != null) {
|
||||||
storage.getOrCreateBlindedIdMapping(sessionId.hexString, openGroup.server, openGroup.publicKey).sessionId?.let {
|
storage.getOrCreateBlindedIdMapping(sessionId.hexString, openGroup.server, openGroup.publicKey).sessionId?.let {
|
||||||
fromSerialized(it)
|
fromSerialized(it)
|
||||||
} ?: run {
|
} ?: GroupUtil.getEncodedOpenGroupInboxID(openGroup, sessionId)
|
||||||
val openGroupInboxId =
|
|
||||||
"${openGroup.server}!${openGroup.publicKey}!${sessionId.hexString}".toByteArray()
|
|
||||||
fromSerialized(GroupUtil.getEncodedOpenGroupInboxID(openGroupInboxId))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
@ -596,7 +592,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||||
|
|
||||||
// called from onCreate
|
// called from onCreate
|
||||||
private fun setUpInputBar() {
|
private fun setUpInputBar() {
|
||||||
binding!!.inputBar.isVisible = viewModel.openGroup == null || viewModel.openGroup?.canWrite == true
|
val recipient = viewModel.recipient ?: return
|
||||||
|
binding!!.inputBar.isVisible =
|
||||||
|
viewModel.openGroup?.canWrite == true
|
||||||
|
|| (viewModel.openGroup == null && !recipient.blocksCommunityMessageRequests)
|
||||||
binding!!.inputBar.delegate = this
|
binding!!.inputBar.delegate = this
|
||||||
binding!!.inputBarRecordingView.delegate = this
|
binding!!.inputBarRecordingView.delegate = this
|
||||||
// GIF button
|
// GIF button
|
||||||
|
@ -1074,6 +1073,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||||
val (textResource, insertParam) = when {
|
val (textResource, insertParam) = when {
|
||||||
recipient.isLocalNumber -> R.string.activity_conversation_empty_state_note_to_self to null
|
recipient.isLocalNumber -> R.string.activity_conversation_empty_state_note_to_self to null
|
||||||
openGroup != null && !openGroup.canWrite -> R.string.activity_conversation_empty_state_read_only to recipient.toShortString()
|
openGroup != null && !openGroup.canWrite -> R.string.activity_conversation_empty_state_read_only to recipient.toShortString()
|
||||||
|
openGroup == null && recipient.blocksCommunityMessageRequests -> R.string.activity_conversation_empty_state_blocks_community_requests to recipient.toShortString()
|
||||||
else -> R.string.activity_conversation_empty_state_default to recipient.toShortString()
|
else -> R.string.activity_conversation_empty_state_default to recipient.toShortString()
|
||||||
}
|
}
|
||||||
val showPlaceholder = adapter.itemCount == 0
|
val showPlaceholder = adapter.itemCount == 0
|
||||||
|
|
|
@ -406,7 +406,7 @@ public class RecipientDatabase extends Database {
|
||||||
ContentValues contentValues = new ContentValues(1);
|
ContentValues contentValues = new ContentValues(1);
|
||||||
contentValues.put(BLOCKS_COMMUNITY_MESSAGE_REQUESTS, isBlocked ? 1 : 0);
|
contentValues.put(BLOCKS_COMMUNITY_MESSAGE_REQUESTS, isBlocked ? 1 : 0);
|
||||||
updateOrInsert(recipient.getAddress(), contentValues);
|
updateOrInsert(recipient.getAddress(), contentValues);
|
||||||
recipient.setBlocksCommunityMessageRequests(isBlocked);
|
recipient.resolve().setBlocksCommunityMessageRequests(isBlocked);
|
||||||
notifyRecipientListeners();
|
notifyRecipientListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,11 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||||
db.setProfileKey(recipient, newProfileKey)
|
db.setProfileKey(recipient, newProfileKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setBlocksCommunityMessageRequests(recipient: Recipient, blocksMessageRequests: Boolean) {
|
||||||
|
val db = DatabaseComponent.get(context).recipientDatabase()
|
||||||
|
db.setBlocksCommunityMessageRequests(recipient, blocksMessageRequests)
|
||||||
|
}
|
||||||
|
|
||||||
override fun setUserProfilePicture(newProfilePicture: String?, newProfileKey: ByteArray?) {
|
override fun setUserProfilePicture(newProfilePicture: String?, newProfileKey: ByteArray?) {
|
||||||
val ourRecipient = fromSerialized(getUserPublicKey()!!).let {
|
val ourRecipient = fromSerialized(getUserPublicKey()!!).let {
|
||||||
Recipient.from(context, it, false)
|
Recipient.from(context, it, false)
|
||||||
|
@ -430,6 +435,10 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||||
return configFactory.canPerformChange(variant, publicKey, changeTimestampMs)
|
return configFactory.canPerformChange(variant, publicKey, changeTimestampMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun isCheckingCommunityRequests(): Boolean {
|
||||||
|
return configFactory.user?.getBlocksCommunityMessageRequests() != true
|
||||||
|
}
|
||||||
|
|
||||||
fun notifyUpdates(forConfigObject: ConfigBase) {
|
fun notifyUpdates(forConfigObject: ConfigBase) {
|
||||||
when (forConfigObject) {
|
when (forConfigObject) {
|
||||||
is UserProfile -> updateUser(forConfigObject)
|
is UserProfile -> updateUser(forConfigObject)
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package org.thoughtcrime.securesms.preferences
|
package org.thoughtcrime.securesms.preferences
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
class PrivacySettingsActivity : PassphraseRequiredActionBarActivity() {
|
class PrivacySettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
||||||
|
|
|
@ -1036,6 +1036,7 @@
|
||||||
<string name="activity_home_outdated_client_config">Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.</string>
|
<string name="activity_home_outdated_client_config">Some of your devices are using outdated versions. Syncing may be unreliable until they are updated.</string>
|
||||||
|
|
||||||
<string name="activity_conversation_empty_state_read_only">There are no messages in <b>%s</b>.</string>
|
<string name="activity_conversation_empty_state_read_only">There are no messages in <b>%s</b>.</string>
|
||||||
|
<string name="activity_conversation_empty_state_blocks_community_requests"><b>%s</b> has message requests from Community conversations turned off, so you cannot send them a message.</string>
|
||||||
<string name="activity_conversation_empty_state_note_to_self">You have no messages in Note to Self.</string>
|
<string name="activity_conversation_empty_state_note_to_self">You have no messages in Note to Self.</string>
|
||||||
<string name="activity_conversation_empty_state_default">You have no messages from <b>%s</b>.\nSend a message to start the conversation!</string>
|
<string name="activity_conversation_empty_state_default">You have no messages from <b>%s</b>.\nSend a message to start the conversation!</string>
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
<PreferenceCategory android:title="@string/preferences__message_requests_category">
|
<PreferenceCategory android:title="@string/preferences__message_requests_category">
|
||||||
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:defaultValue="false"
|
android:key="libsession.ALLOW_MESSAGE_REQUESTS"
|
||||||
android:key="libsession.BLOCK_MESSAGE_REQUESTS"
|
|
||||||
android:title="@string/preferences__message_requests_title"
|
android:title="@string/preferences__message_requests_title"
|
||||||
android:summary="@string/preferences__message_requests_summary"
|
android:summary="@string/preferences__message_requests_summary"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -106,7 +106,7 @@ Java_network_loki_messenger_libsession_1util_UserProfile_getBlocksCommunityMessa
|
||||||
if (blinded_msg_requests.has_value()) {
|
if (blinded_msg_requests.has_value()) {
|
||||||
return *blinded_msg_requests;
|
return *blinded_msg_requests;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
|
@ -42,6 +42,7 @@ interface StorageProtocol {
|
||||||
fun getUserProfile(): Profile
|
fun getUserProfile(): Profile
|
||||||
fun setProfileAvatar(recipient: Recipient, profileAvatar: String?)
|
fun setProfileAvatar(recipient: Recipient, profileAvatar: String?)
|
||||||
fun setProfilePicture(recipient: Recipient, newProfilePicture: String?, newProfileKey: ByteArray?)
|
fun setProfilePicture(recipient: Recipient, newProfilePicture: String?, newProfileKey: ByteArray?)
|
||||||
|
fun setBlocksCommunityMessageRequests(recipient: Recipient, blocksMessageRequests: Boolean)
|
||||||
fun setUserProfilePicture(newProfilePicture: String?, newProfileKey: ByteArray?)
|
fun setUserProfilePicture(newProfilePicture: String?, newProfileKey: ByteArray?)
|
||||||
fun clearUserPic()
|
fun clearUserPic()
|
||||||
// Signal
|
// Signal
|
||||||
|
@ -228,4 +229,5 @@ interface StorageProtocol {
|
||||||
fun notifyConfigUpdates(forConfigObject: ConfigBase)
|
fun notifyConfigUpdates(forConfigObject: ConfigBase)
|
||||||
fun conversationInConfig(publicKey: String?, groupPublicKey: String?, openGroupId: String?, visibleOnly: Boolean): Boolean
|
fun conversationInConfig(publicKey: String?, groupPublicKey: String?, openGroupId: String?, visibleOnly: Boolean): Boolean
|
||||||
fun canPerformConfigChange(variant: String, publicKey: String, changeTimestampMs: Long): Boolean
|
fun canPerformConfigChange(variant: String, publicKey: String, changeTimestampMs: Long): Boolean
|
||||||
|
fun isCheckingCommunityRequests(): Boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -753,7 +753,8 @@ object OpenGroupApi {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val serverCapabilities = storage.getServerCapabilities(server)
|
val serverCapabilities = storage.getServerCapabilities(server)
|
||||||
if (serverCapabilities.contains(Capability.BLIND.name.lowercase())) {
|
val isAcceptingCommunityRequests = storage.isCheckingCommunityRequests()
|
||||||
|
if (serverCapabilities.contains(Capability.BLIND.name.lowercase()) && isAcceptingCommunityRequests) {
|
||||||
requests.add(
|
requests.add(
|
||||||
if (lastInboxMessageId == null) {
|
if (lastInboxMessageId == null) {
|
||||||
BatchRequestInfo(
|
BatchRequestInfo(
|
||||||
|
|
|
@ -261,7 +261,17 @@ fun MessageReceiver.handleVisibleMessage(
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val context = MessagingModuleConfiguration.shared.context
|
val context = MessagingModuleConfiguration.shared.context
|
||||||
val userPublicKey = storage.getUserPublicKey()
|
val userPublicKey = storage.getUserPublicKey()
|
||||||
val messageSender: String? = message.sender
|
val openGroup = if (!openGroupID.isNullOrEmpty()) {
|
||||||
|
storage.getThreadId(Address.fromSerialized(GroupUtil.getEncodedOpenGroupID(openGroupID.toByteArray())))?.let {
|
||||||
|
storage.getOpenGroup(it)
|
||||||
|
}
|
||||||
|
} else null
|
||||||
|
val senderId = SessionId(message.sender!!)
|
||||||
|
val messageSender: String? = if (openGroup != null && senderId.prefix == IdPrefix.BLINDED) {
|
||||||
|
message.sender?.let {
|
||||||
|
GroupUtil.getEncodedOpenGroupInboxID(openGroup, SessionId(it)).serialize()
|
||||||
|
}
|
||||||
|
} else message.sender
|
||||||
|
|
||||||
// Do nothing if the message was outdated
|
// Do nothing if the message was outdated
|
||||||
if (MessageReceiver.messageIsOutdated(message, threadId, openGroupID)) { return null }
|
if (MessageReceiver.messageIsOutdated(message, threadId, openGroupID)) { return null }
|
||||||
|
@ -306,7 +316,7 @@ fun MessageReceiver.handleVisibleMessage(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userPublicKey != messageSender && !isUserBlindedSender) {
|
if (userPublicKey != messageSender && !isUserBlindedSender) {
|
||||||
recipient.setBlocksCommunityMessageRequests(message.blocksMessageRequests)
|
storage.setBlocksCommunityMessageRequests(recipient, message.blocksMessageRequests)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Parse quote if needed
|
// Parse quote if needed
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.session.libsession.utilities
|
package org.session.libsession.utilities
|
||||||
|
|
||||||
import network.loki.messenger.libsession_util.util.GroupInfo
|
import org.session.libsession.messaging.open_groups.OpenGroup
|
||||||
|
import org.session.libsession.messaging.utilities.SessionId
|
||||||
import org.session.libsignal.messages.SignalServiceGroup
|
import org.session.libsignal.messages.SignalServiceGroup
|
||||||
import org.session.libsignal.utilities.Hex
|
import org.session.libsignal.utilities.Hex
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
@ -15,6 +16,13 @@ object GroupUtil {
|
||||||
return OPEN_GROUP_PREFIX + Hex.toStringCondensed(groupID)
|
return OPEN_GROUP_PREFIX + Hex.toStringCondensed(groupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun getEncodedOpenGroupInboxID(openGroup: OpenGroup, sessionId: SessionId): Address {
|
||||||
|
val openGroupInboxId =
|
||||||
|
"${openGroup.server}!${openGroup.publicKey}!${sessionId.hexString}".toByteArray()
|
||||||
|
return Address.fromSerialized(getEncodedOpenGroupInboxID(openGroupInboxId))
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getEncodedOpenGroupInboxID(groupInboxID: ByteArray): String {
|
fun getEncodedOpenGroupInboxID(groupInboxID: ByteArray): String {
|
||||||
return OPEN_GROUP_INBOX_PREFIX + Hex.toStringCondensed(groupInboxID)
|
return OPEN_GROUP_INBOX_PREFIX + Hex.toStringCondensed(groupInboxID)
|
||||||
|
|
|
@ -349,6 +349,10 @@ public class Recipient implements RecipientModifiedListener {
|
||||||
if (notify) notifyListeners();
|
if (notify) notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getBlocksCommunityMessageRequests() {
|
||||||
|
return blocksCommunityMessageRequests;
|
||||||
|
}
|
||||||
|
|
||||||
public void setBlocksCommunityMessageRequests(boolean blocksCommunityMessageRequests) {
|
public void setBlocksCommunityMessageRequests(boolean blocksCommunityMessageRequests) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
this.blocksCommunityMessageRequests = blocksCommunityMessageRequests;
|
this.blocksCommunityMessageRequests = blocksCommunityMessageRequests;
|
||||||
|
|
Loading…
Reference in New Issue