Skip to content

Commit

Permalink
Don't prompt for auto-initiate if push registered (or active V2).
Browse files Browse the repository at this point in the history
  • Loading branch information
moxie0 committed Feb 20, 2014
1 parent 5b22a7b commit c5821f7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/org/thoughtcrime/securesms/AutoInitiateActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
import android.widget.Button;

import org.thoughtcrime.securesms.crypto.KeyExchangeInitiator;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.textsecure.crypto.MasterSecret;
import org.whispersystems.textsecure.storage.LocalKeyRecord;
import org.whispersystems.textsecure.storage.RecipientDevice;
import org.whispersystems.textsecure.storage.RemoteKeyRecord;
import org.thoughtcrime.securesms.protocol.Tag;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.MemoryCleaner;
import org.whispersystems.textsecure.storage.SessionRecordV2;

/**
* Activity which prompts the user to initiate a secure
Expand Down Expand Up @@ -100,8 +103,9 @@ public static boolean isValidAutoInitiateSituation(Context context, MasterSecret
Recipient recipient, String message, long threadId)
{
return
Tag.isTagged(message) &&
isThreadQualified(context, threadId) &&
Tag.isTagged(message) &&
TextSecurePreferences.isPushRegistered(context) &&
isThreadQualified(context, threadId) &&
isExchangeQualified(context, masterSecret, recipient);
}

Expand All @@ -113,6 +117,7 @@ private static boolean isThreadQualified(Context context, long threadId) {
private static boolean isExchangeQualified(Context context, MasterSecret masterSecret, Recipient recipient) {
return
(new RemoteKeyRecord(context,recipient).getCurrentRemoteKey() == null) &&
(new LocalKeyRecord(context, masterSecret, recipient).getCurrentKeyPair() == null);
(new LocalKeyRecord(context, masterSecret, recipient).getCurrentKeyPair() == null) &&
!SessionRecordV2.hasSession(context, masterSecret, recipient.getRecipientId(), RecipientDevice.DEFAULT_DEVICE_ID);
}
}

0 comments on commit c5821f7

Please sign in to comment.