From 85336238a7bec3becb2a63e3b11ae88fcc91dbb5 Mon Sep 17 00:00:00 2001 From: jubb Date: Fri, 26 Feb 2021 10:08:30 +1100 Subject: [PATCH 1/2] fix: return early if no profile name (prefs likely invalid state) and ignore contacts whose publicKey fails to parse --- .../securesms/loki/protocol/MultiDeviceProtocol.kt | 4 ++-- .../messaging/messages/control/ConfigurationMessage.kt | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt index 387108f3a6..8b52e01663 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/MultiDeviceProtocol.kt @@ -34,7 +34,7 @@ object MultiDeviceProtocol { }.map { recipient -> ConfigurationMessage.Contact(recipient.address.serialize(), recipient.name!!, recipient.profileAvatar, recipient.profileKey) } - val configurationMessage = ConfigurationMessage.getCurrent(contacts) + val configurationMessage = ConfigurationMessage.getCurrent(contacts) ?: return val serializedMessage = configurationMessage.toProto()!!.toByteArray() val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender() val address = SignalServiceAddress(userPublicKey) @@ -58,7 +58,7 @@ object MultiDeviceProtocol { }.map { recipient -> ConfigurationMessage.Contact(recipient.address.serialize(), recipient.name!!, recipient.profileAvatar, recipient.profileKey) } - val configurationMessage = ConfigurationMessage.getCurrent(contacts) + val configurationMessage = ConfigurationMessage.getCurrent(contacts) ?: return val serializedMessage = configurationMessage.toProto()!!.toByteArray() val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender() val address = SignalServiceAddress(userPublicKey) diff --git a/libsession/src/main/java/org/session/libsession/messaging/messages/control/ConfigurationMessage.kt b/libsession/src/main/java/org/session/libsession/messaging/messages/control/ConfigurationMessage.kt index 421c58c585..846413ce96 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/messages/control/ConfigurationMessage.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/messages/control/ConfigurationMessage.kt @@ -67,7 +67,11 @@ class ConfigurationMessage(val closedGroups: List, val openGroups: fun toProto(): SignalServiceProtos.ConfigurationMessage.Contact? { val result = SignalServiceProtos.ConfigurationMessage.Contact.newBuilder() result.name = this.name - result.publicKey = ByteString.copyFrom(Hex.fromStringCondensed(publicKey)) + try { + result.publicKey = ByteString.copyFrom(Hex.fromStringCondensed(publicKey)) + } catch (e: Exception) { + return null + } if (!this.profilePicture.isNullOrEmpty()) { result.profilePicture = this.profilePicture } @@ -83,13 +87,13 @@ class ConfigurationMessage(val closedGroups: List, val openGroups: companion object { - fun getCurrent(contacts: List): ConfigurationMessage { + fun getCurrent(contacts: List): ConfigurationMessage? { val closedGroups = mutableListOf() val openGroups = mutableListOf() val sharedConfig = MessagingConfiguration.shared val storage = sharedConfig.storage val context = sharedConfig.context - val displayName = TextSecurePreferences.getProfileName(context)!! + val displayName = TextSecurePreferences.getProfileName(context) ?: return null val profilePicture = TextSecurePreferences.getProfilePictureURL(context) val profileKey = ProfileKeyUtil.getProfileKey(context) val groups = storage.getAllGroups() From 242eb90d2151f8b47b676487b97c0af7d4ec0c8f Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 26 Feb 2021 10:15:24 +1100 Subject: [PATCH 2/2] Update version number --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d6e5b88067..6f84c6ca8d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -158,8 +158,8 @@ dependencies { testImplementation 'org.robolectric:shadows-multidex:4.2' } -def canonicalVersionCode = 141 -def canonicalVersionName = "1.7.3" +def canonicalVersionCode = 142 +def canonicalVersionName = "1.7.4" def postFixSize = 10 def abiPostFix = ['armeabi-v7a' : 1,