From 6d521e4227827a6267db59b26fd3ce03ffdca77e Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 22 Jul 2019 16:22:40 +1000 Subject: [PATCH] Send session reset request acknowledgement if needed --- .../securesms/conversation/ConversationActivity.java | 4 +--- .../securesms/conversation/ConversationFragment.java | 2 +- .../thoughtcrime/securesms/jobs/PushDecryptJob.java | 11 ++++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index bdf242292e..6833d4fbd4 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -213,7 +213,6 @@ import org.thoughtcrime.securesms.util.views.Stub; import org.whispersystems.libsignal.InvalidMessageException; import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.signalservice.api.SignalServiceMessageSender; -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.loki.messaging.LokiThreadFriendRequestStatus; @@ -2718,9 +2717,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity SignalServiceMessageSender messageSender = ApplicationContext.getInstance(this).communicationModule.provideSignalMessageSender(); SignalServiceAddress address = new SignalServiceAddress(contactID); SignalServiceDataMessage message = new SignalServiceDataMessage(System.currentTimeMillis(), ""); - Optional access = Optional.absent(); try { - messageSender.sendMessage(0, address, access, message); // The message ID doesn't matter + messageSender.sendMessage(0, address, Optional.absent(), message); // The message ID doesn't matter } catch (Exception e) { Log.d("Loki", "Failed to send empty message to: " + contactID + "."); } diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java b/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java index e0938ea114..a006c61edf 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java @@ -655,7 +655,7 @@ public class ConversationFragment extends Fragment } if (!loader.hasSent() && !recipient.isSystemContact() && !recipient.isGroupRecipient() && recipient.getRegistered() == RecipientDatabase.RegisteredState.REGISTERED) { - adapter.setHeaderView(unknownSenderView); + // adapter.setHeaderView(unknownSenderView); } else { clearHeaderIfNotTyping(adapter); } diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 5d1bc083b7..12e3cfdc6a 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -476,9 +476,18 @@ public class PushDecryptJob extends BaseJob implements InjectableType { sessionStore.archiveAllSessions(content.getSender()); lokiThreadDatabase.setSessionResetStatus(threadId, LokiThreadSessionResetStatus.REQUEST_RECEIVED); - // TODO: Send a background message here Log.d("Loki", "Received a session reset request from: " + content.getSender() + "."); + String contactID = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId).getAddress().toString(); + SignalServiceMessageSender messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender(); + SignalServiceAddress address = new SignalServiceAddress(contactID); + SignalServiceDataMessage message = new SignalServiceDataMessage(System.currentTimeMillis(), ""); + try { + messageSender.sendMessage(0, address, Optional.absent(), message); // The message ID doesn't matter + } catch (Exception e) { + Log.d("Loki", "Failed to send empty message to: " + contactID + "."); + } + SecurityEvent.broadcastSecurityUpdateEvent(context); MessageNotifier.updateNotification(context, threadId); }