mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 12:35:17 +00:00
5602a3dfc0
1) Switch to new TextSecureAddress addressing, rather than mixing long-based recipient IDs into libtextsecure. 2) Get rid of RecipientFormattingException throws in calls to RecipientFactory. Closes #2570
25 lines
986 B
Java
25 lines
986 B
Java
package org.thoughtcrime.securesms.crypto;
|
|
|
|
import android.content.Context;
|
|
import android.support.annotation.NonNull;
|
|
|
|
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
|
import org.whispersystems.libaxolotl.AxolotlAddress;
|
|
import org.whispersystems.libaxolotl.state.SessionStore;
|
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
|
|
|
public class SessionUtil {
|
|
|
|
public static boolean hasSession(Context context, MasterSecret masterSecret, Recipient recipient) {
|
|
return hasSession(context, masterSecret, recipient.getNumber());
|
|
}
|
|
|
|
public static boolean hasSession(Context context, MasterSecret masterSecret, @NonNull String number) {
|
|
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
|
AxolotlAddress axolotlAddress = new AxolotlAddress(number, TextSecureAddress.DEFAULT_DEVICE_ID);
|
|
|
|
return sessionStore.containsSession(axolotlAddress);
|
|
}
|
|
}
|