Send session reset request acknowledgement if needed

This commit is contained in:
Niels Andriesse 2019-07-22 16:22:40 +10:00
parent 9be8d75773
commit 6d521e4227
3 changed files with 12 additions and 5 deletions

View File

@ -213,7 +213,6 @@ import org.thoughtcrime.securesms.util.views.Stub;
import org.whispersystems.libsignal.InvalidMessageException; import org.whispersystems.libsignal.InvalidMessageException;
import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.SignalServiceMessageSender; 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.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.push.SignalServiceAddress; import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus; import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
@ -2718,9 +2717,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
SignalServiceMessageSender messageSender = ApplicationContext.getInstance(this).communicationModule.provideSignalMessageSender(); SignalServiceMessageSender messageSender = ApplicationContext.getInstance(this).communicationModule.provideSignalMessageSender();
SignalServiceAddress address = new SignalServiceAddress(contactID); SignalServiceAddress address = new SignalServiceAddress(contactID);
SignalServiceDataMessage message = new SignalServiceDataMessage(System.currentTimeMillis(), ""); SignalServiceDataMessage message = new SignalServiceDataMessage(System.currentTimeMillis(), "");
Optional<UnidentifiedAccessPair> access = Optional.absent();
try { 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) { } catch (Exception e) {
Log.d("Loki", "Failed to send empty message to: " + contactID + "."); Log.d("Loki", "Failed to send empty message to: " + contactID + ".");
} }

View File

@ -655,7 +655,7 @@ public class ConversationFragment extends Fragment
} }
if (!loader.hasSent() && !recipient.isSystemContact() && !recipient.isGroupRecipient() && recipient.getRegistered() == RecipientDatabase.RegisteredState.REGISTERED) { if (!loader.hasSent() && !recipient.isSystemContact() && !recipient.isGroupRecipient() && recipient.getRegistered() == RecipientDatabase.RegisteredState.REGISTERED) {
adapter.setHeaderView(unknownSenderView); // adapter.setHeaderView(unknownSenderView);
} else { } else {
clearHeaderIfNotTyping(adapter); clearHeaderIfNotTyping(adapter);
} }

View File

@ -476,9 +476,18 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
sessionStore.archiveAllSessions(content.getSender()); sessionStore.archiveAllSessions(content.getSender());
lokiThreadDatabase.setSessionResetStatus(threadId, LokiThreadSessionResetStatus.REQUEST_RECEIVED); lokiThreadDatabase.setSessionResetStatus(threadId, LokiThreadSessionResetStatus.REQUEST_RECEIVED);
// TODO: Send a background message here
Log.d("Loki", "Received a session reset request from: " + content.getSender() + "."); 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); SecurityEvent.broadcastSecurityUpdateEvent(context);
MessageNotifier.updateNotification(context, threadId); MessageNotifier.updateNotification(context, threadId);
} }