From 45d78825a037a55257ce078ce934c3160cb492f4 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 12 Feb 2020 16:25:14 +1100 Subject: [PATCH] Clean --- .../securesms/jobs/PushDecryptJob.java | 14 +++++++------- .../securesms/loki/MultiDeviceUtilities.kt | 2 +- .../securesms/loki/PushBackgroundMessageSendJob.kt | 4 +--- .../securesms/push/MessageSenderEventListener.java | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 6d0f70316d..0ef8ce54f8 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -297,7 +297,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { // Loki - Store pre key bundle // We shouldn't store it if it's a pairing message - if (!content.getPairingAuthorisation().isPresent()) { + if (!content.getDeviceLink().isPresent()) { storePreKeyBundleIfNeeded(content); } @@ -324,13 +324,13 @@ public class PushDecryptJob extends BaseJob implements InjectableType { }); } - if (content.getPairingAuthorisation().isPresent()) { - handlePairingMessage(content.getPairingAuthorisation().get(), content); + if (content.getDeviceLink().isPresent()) { + handlePairingMessage(content.getDeviceLink().get(), content); } else if (content.getDataMessage().isPresent()) { SignalServiceDataMessage message = content.getDataMessage().get(); boolean isMediaMessage = message.getAttachments().isPresent() || message.getQuote().isPresent() || message.getSharedContacts().isPresent() || message.getPreviews().isPresent() || message.getSticker().isPresent(); - if (!content.isFriendRequest() && message.isUnpairingRequest()) { + if (!content.isFriendRequest() && message.isUnlinkingRequest()) { // Make sure we got the request from our primary device String ourPrimaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context); if (ourPrimaryDevice != null && ourPrimaryDevice.equals(content.getSender())) { @@ -339,7 +339,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { } } else { // Loki - Don't process session restore message any further - if (message.isSessionRestore() || message.isSessionRequest()) { return; } + if (message.isSessionRestorationRequest() || message.isSessionRequest()) { return; } if (message.isEndSession()) handleEndSessionMessage(content, smsMessageId); else if (message.isGroupUpdate()) handleGroupMessage(content, message, smsMessageId); @@ -1538,7 +1538,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { if (recipient.getProfileKey() == null || !MessageDigest.isEqual(recipient.getProfileKey(), message.getProfileKey().get())) { database.setProfileKey(recipient, message.getProfileKey().get()); database.setUnidentifiedAccessMode(recipient, RecipientDatabase.UnidentifiedAccessMode.UNKNOWN); - String url = content.senderProfileAvatarUrl.or(""); + String url = content.senderProfilePictureURL.or(""); ApplicationContext.getInstance(context).getJobManager().add(new RetrieveProfileAvatarJob(recipient, url)); // Loki - If the recipient is our master device then we need to go and update our avatar mappings on the public chats @@ -1832,7 +1832,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { Recipient sender = Recipient.from(context, Address.fromSerialized(content.getSender()), false); - if (content.getPairingAuthorisation().isPresent()) { + if (content.getDeviceLink().isPresent()) { return false; } else if (content.getDataMessage().isPresent()) { SignalServiceDataMessage message = content.getDataMessage().get(); diff --git a/src/org/thoughtcrime/securesms/loki/MultiDeviceUtilities.kt b/src/org/thoughtcrime/securesms/loki/MultiDeviceUtilities.kt index d5c256f52b..bfb7da57bf 100644 --- a/src/org/thoughtcrime/securesms/loki/MultiDeviceUtilities.kt +++ b/src/org/thoughtcrime/securesms/loki/MultiDeviceUtilities.kt @@ -112,7 +112,7 @@ fun shouldAutomaticallyBecomeFriendsWithDevice(publicKey: String, context: Conte fun sendPairingAuthorisationMessage(context: Context, contactHexEncodedPublicKey: String, authorisation: DeviceLink): Promise { val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender() val address = SignalServiceAddress(contactHexEncodedPublicKey) - val message = SignalServiceDataMessage.newBuilder().withPairingAuthorisation(authorisation) + val message = SignalServiceDataMessage.newBuilder().withDeviceLink(authorisation) // A REQUEST should always act as a friend request. A GRANT should always be replying back as a normal message. if (authorisation.type == DeviceLink.Type.REQUEST) { val preKeyBundle = DatabaseFactory.getLokiPreKeyBundleDatabase(context).generatePreKeyBundle(address.number) diff --git a/src/org/thoughtcrime/securesms/loki/PushBackgroundMessageSendJob.kt b/src/org/thoughtcrime/securesms/loki/PushBackgroundMessageSendJob.kt index 8aa084eb54..0a3f00e7e7 100644 --- a/src/org/thoughtcrime/securesms/loki/PushBackgroundMessageSendJob.kt +++ b/src/org/thoughtcrime/securesms/loki/PushBackgroundMessageSendJob.kt @@ -10,8 +10,6 @@ import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint import org.thoughtcrime.securesms.jobs.BaseJob import org.thoughtcrime.securesms.logging.Log import org.thoughtcrime.securesms.recipients.Recipient -import org.whispersystems.libsignal.util.guava.Optional -import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage import org.whispersystems.signalservice.api.push.SignalServiceAddress import org.whispersystems.signalservice.internal.util.JsonUtil @@ -99,7 +97,7 @@ class PushBackgroundMessageSendJob private constructor( } if (message.get("sessionRestore", false)) { - dataMessage.asSessionRestore(true) + dataMessage.asSessionRestorationRequest(true) } if (message.get("sessionRequest", false)) { diff --git a/src/org/thoughtcrime/securesms/push/MessageSenderEventListener.java b/src/org/thoughtcrime/securesms/push/MessageSenderEventListener.java index 5cc2d886c1..86850399d3 100644 --- a/src/org/thoughtcrime/securesms/push/MessageSenderEventListener.java +++ b/src/org/thoughtcrime/securesms/push/MessageSenderEventListener.java @@ -38,7 +38,7 @@ public class MessageSenderEventListener implements SignalServiceMessageSender.Ev FriendRequestHandler.updateFriendRequestState(context, FriendRequestHandler.ActionType.Sent, messageID, threadID); } - @Override public void onFriendRequestSendingFail(long messageID, long threadID) { + @Override public void onFriendRequestSendingFailed(long messageID, long threadID) { FriendRequestHandler.updateFriendRequestState(context, FriendRequestHandler.ActionType.Failed, messageID, threadID); } }