diff --git a/src/org/thoughtcrime/securesms/jobs/MultiDeviceContactUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/MultiDeviceContactUpdateJob.java index 6479ef0b64..aa22fa51e5 100644 --- a/src/org/thoughtcrime/securesms/jobs/MultiDeviceContactUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MultiDeviceContactUpdateJob.java @@ -29,6 +29,8 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.whispersystems.libsignal.IdentityKey; import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.signalservice.api.SignalServiceMessageSender; +import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess; +import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair; import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException; import org.whispersystems.signalservice.api.messages.SignalServiceAttachment; import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream; @@ -285,9 +287,12 @@ public class MultiDeviceContactUpdateJob extends BaseJob implements InjectableTy .build(); SignalServiceAddress messageRecipient = recipient != null ? new SignalServiceAddress(recipient) : null; + Address address = recipient != null ? Address.fromSerialized(recipient) : null; + + Optional unidentifiedAccess = address != null ? UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, address, false)) : Optional.absent(); try { - messageSender.sendMessage(0, SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, complete)), messageRecipient); + messageSender.sendMessage(0, SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, complete)), unidentifiedAccess, Optional.fromNullable(messageRecipient)); } catch (IOException ioe) { throw new NetworkException(ioe); } diff --git a/src/org/thoughtcrime/securesms/loki/PushMessageSyncSendJob.kt b/src/org/thoughtcrime/securesms/loki/PushMessageSyncSendJob.kt index f18e941fda..87d19cf9c2 100644 --- a/src/org/thoughtcrime/securesms/loki/PushMessageSyncSendJob.kt +++ b/src/org/thoughtcrime/securesms/loki/PushMessageSyncSendJob.kt @@ -1,11 +1,13 @@ package org.thoughtcrime.securesms.loki +import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil import org.thoughtcrime.securesms.database.Address import org.thoughtcrime.securesms.dependencies.InjectableType import org.thoughtcrime.securesms.jobmanager.Data import org.thoughtcrime.securesms.jobmanager.Job import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint import org.thoughtcrime.securesms.jobs.BaseJob +import org.thoughtcrime.securesms.recipients.Recipient import org.whispersystems.signalservice.api.SignalServiceMessageSender import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException import org.whispersystems.signalservice.api.push.SignalServiceAddress @@ -63,7 +65,8 @@ class PushMessageSyncSendJob private constructor( public override fun onRun() { // Don't send sync messages to a group if (recipient.isGroup || recipient.isEmail) { return } - messageSender.lokiSendSyncMessage(messageID, SignalServiceAddress(recipient.toPhoneString()), timestamp, message, ttl) + val unidentifiedAccess = UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, recipient, false)) + messageSender.lokiSendSyncMessage(messageID, SignalServiceAddress(recipient.toPhoneString()), unidentifiedAccess, timestamp, message, ttl) } public override fun onShouldRetry(e: Exception): Boolean { diff --git a/src/org/thoughtcrime/securesms/recipients/Recipient.java b/src/org/thoughtcrime/securesms/recipients/Recipient.java index ec0b3a8410..8e61e4900c 100644 --- a/src/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/src/org/thoughtcrime/securesms/recipients/Recipient.java @@ -101,7 +101,7 @@ public class Recipient implements RecipientModifiedListener { private String notificationChannel; private boolean forceSmsSelection; - private @NonNull UnidentifiedAccessMode unidentifiedAccessMode = UnidentifiedAccessMode.DISABLED; + private @NonNull UnidentifiedAccessMode unidentifiedAccessMode = UnidentifiedAccessMode.ENABLED; @SuppressWarnings("ConstantConditions") public static @NonNull Recipient from(@NonNull Context context, @NonNull Address address, boolean asynchronous) { diff --git a/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java b/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java index e6729ff233..d2a9ae3364 100644 --- a/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java +++ b/src/org/thoughtcrime/securesms/util/TextSecurePreferences.java @@ -601,7 +601,9 @@ public class TextSecurePreferences { } public static boolean isUnidentifiedDeliveryEnabled(Context context) { - return getBooleanPreference(context, UNIDENTIFIED_DELIVERY_ENABLED, true); + // Loki - Always enable unidentified sender + return true; + // return getBooleanPreference(context, UNIDENTIFIED_DELIVERY_ENABLED, true); } public static long getSignedPreKeyRotationTime(Context context) {