mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Resolve TODO
This commit is contained in:
parent
e8bece45b9
commit
ca370211f8
@ -107,7 +107,10 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
private IncomingMessageObserver incomingMessageObserver;
|
private IncomingMessageObserver incomingMessageObserver;
|
||||||
private ObjectGraph objectGraph;
|
private ObjectGraph objectGraph;
|
||||||
private PersistentLogger persistentLogger;
|
private PersistentLogger persistentLogger;
|
||||||
private LokiLongPoller lokiLongPoller = null; // Loki
|
|
||||||
|
// Loki
|
||||||
|
private LokiLongPoller lokiLongPoller = null;
|
||||||
|
public SignalCommunicationModule communicationModule;
|
||||||
|
|
||||||
private volatile boolean isAppVisible;
|
private volatile boolean isAppVisible;
|
||||||
|
|
||||||
@ -244,8 +247,8 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeDependencyInjection() {
|
private void initializeDependencyInjection() {
|
||||||
this.objectGraph = ObjectGraph.create(new SignalCommunicationModule(this, new SignalServiceNetworkAccess(this)),
|
communicationModule = new SignalCommunicationModule(this, new SignalServiceNetworkAccess(this));
|
||||||
new AxolotlStorageModule(this));
|
this.objectGraph = ObjectGraph.create(communicationModule, new AxolotlStorageModule(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeGcmCheck() {
|
private void initializeGcmCheck() {
|
||||||
|
@ -145,7 +145,6 @@ import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
|||||||
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
|
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
|
||||||
import org.thoughtcrime.securesms.giph.ui.GiphyActivity;
|
import org.thoughtcrime.securesms.giph.ui.GiphyActivity;
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
|
||||||
import org.thoughtcrime.securesms.jobs.PushDecryptJob;
|
|
||||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileJob;
|
import org.thoughtcrime.securesms.jobs.RetrieveProfileJob;
|
||||||
import org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob;
|
import org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob;
|
||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
||||||
@ -211,6 +210,10 @@ import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
|
|||||||
import org.thoughtcrime.securesms.util.views.Stub;
|
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.crypto.UnidentifiedAccessPair;
|
||||||
|
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||||
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
|
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -2689,7 +2692,15 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
public void acceptFriendRequest(@NotNull MessageRecord friendRequest) {
|
public void acceptFriendRequest(@NotNull MessageRecord friendRequest) {
|
||||||
DatabaseFactory.getLokiThreadFriendRequestDatabase(this).setFriendRequestStatus(this.threadId, LokiThreadFriendRequestStatus.FRIENDS);
|
DatabaseFactory.getLokiThreadFriendRequestDatabase(this).setFriendRequestStatus(this.threadId, LokiThreadFriendRequestStatus.FRIENDS);
|
||||||
String contactID = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(this.threadId).getAddress().toString();
|
String contactID = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(this.threadId).getAddress().toString();
|
||||||
new PushDecryptJob(this).sendEmptyMessage(contactID); // TODO: Use a better approach for this
|
SignalServiceMessageSender messageSender = ApplicationContext.getInstance(this).communicationModule.provideSignalMessageSender();
|
||||||
|
SignalServiceAddress address = new SignalServiceAddress(contactID);
|
||||||
|
SignalServiceDataMessage message = new SignalServiceDataMessage(System.currentTimeMillis(), "");
|
||||||
|
Optional<UnidentifiedAccessPair> access = Optional.absent();
|
||||||
|
try {
|
||||||
|
messageSender.sendMessage(0, address, access, message); // The message ID doesn't matter
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.d("Loki", "Failed to send empty message to: " + contactID + ".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +47,7 @@ public class TextSecureIdentityKeyStore implements IdentityKeyStore {
|
|||||||
public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey, boolean nonBlockingApproval) {
|
public boolean saveIdentity(SignalProtocolAddress address, IdentityKey identityKey, boolean nonBlockingApproval) {
|
||||||
synchronized (LOCK) {
|
synchronized (LOCK) {
|
||||||
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
|
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
|
||||||
Address signalAddress = Address.fromExternal(context, address.getName());
|
Address signalAddress = Address.fromSerialized(address.getName());
|
||||||
Optional<IdentityRecord> identityRecord = identityDatabase.getIdentity(signalAddress);
|
Optional<IdentityRecord> identityRecord = identityDatabase.getIdentity(signalAddress);
|
||||||
|
|
||||||
if (!identityRecord.isPresent()) {
|
if (!identityRecord.isPresent()) {
|
||||||
@ -94,7 +94,7 @@ public class TextSecureIdentityKeyStore implements IdentityKeyStore {
|
|||||||
synchronized (LOCK) {
|
synchronized (LOCK) {
|
||||||
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
|
IdentityDatabase identityDatabase = DatabaseFactory.getIdentityDatabase(context);
|
||||||
String ourNumber = TextSecurePreferences.getLocalNumber(context);
|
String ourNumber = TextSecurePreferences.getLocalNumber(context);
|
||||||
Address theirAddress = Address.fromExternal(context, address.getName());
|
Address theirAddress = Address.fromSerialized(address.getName());
|
||||||
|
|
||||||
if (ourNumber.equals(address.getName()) || Address.fromSerialized(ourNumber).equals(theirAddress)) {
|
if (ourNumber.equals(address.getName()) || Address.fromSerialized(ourNumber).equals(theirAddress)) {
|
||||||
return identityKey.equals(IdentityKeyUtil.getIdentityKey(context));
|
return identityKey.equals(IdentityKeyUtil.getIdentityKey(context));
|
||||||
|
@ -66,7 +66,7 @@ public class Address implements Parcelable, Comparable<Address> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Address fromExternal(@NonNull Context context, @Nullable String external) {
|
public static Address fromExternal(@NonNull Context context, @Nullable String external) {
|
||||||
return new Address(getExternalAddressFormatter(context).format(external));
|
return Address.fromSerialized(external);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NonNull List<Address> fromSerializedList(@NonNull String serialized, char delimiter) {
|
public static @NonNull List<Address> fromSerializedList(@NonNull String serialized, char delimiter) {
|
||||||
|
@ -42,7 +42,6 @@ import org.thoughtcrime.securesms.jobs.SendDeliveryReceiptJob;
|
|||||||
import org.thoughtcrime.securesms.jobs.SendReadReceiptJob;
|
import org.thoughtcrime.securesms.jobs.SendReadReceiptJob;
|
||||||
import org.thoughtcrime.securesms.jobs.TypingSendJob;
|
import org.thoughtcrime.securesms.jobs.TypingSendJob;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.loki.LokiPreKeyBundleDatabase;
|
|
||||||
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
|
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
|
||||||
import org.thoughtcrime.securesms.push.SecurityEventListener;
|
import org.thoughtcrime.securesms.push.SecurityEventListener;
|
||||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||||
@ -127,7 +126,7 @@ public class SignalCommunicationModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
synchronized SignalServiceMessageSender provideSignalMessageSender() {
|
public synchronized SignalServiceMessageSender provideSignalMessageSender() {
|
||||||
if (this.messageSender == null) {
|
if (this.messageSender == null) {
|
||||||
this.messageSender = new SignalServiceMessageSender(networkAccess.getConfiguration(context),
|
this.messageSender = new SignalServiceMessageSender(networkAccess.getConfiguration(context),
|
||||||
new DynamicCredentialsProvider(context),
|
new DynamicCredentialsProvider(context),
|
||||||
|
@ -17,6 +17,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
|
|||||||
import org.thoughtcrime.securesms.database.IdentityDatabase
|
import org.thoughtcrime.securesms.database.IdentityDatabase
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.libsignal.IdentityKeyPair
|
import org.whispersystems.libsignal.IdentityKeyPair
|
||||||
|
import org.whispersystems.libsignal.util.KeyHelper
|
||||||
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
||||||
import org.whispersystems.signalservice.loki.utilities.hexEncodedPrivateKey
|
import org.whispersystems.signalservice.loki.utilities.hexEncodedPrivateKey
|
||||||
import org.whispersystems.signalservice.loki.utilities.hexEncodedPublicKey
|
import org.whispersystems.signalservice.loki.utilities.hexEncodedPublicKey
|
||||||
@ -90,6 +91,8 @@ class KeyPairActivity : BaseActionBarActivity() {
|
|||||||
private fun register() {
|
private fun register() {
|
||||||
val publicKey = keyPair!!.publicKey
|
val publicKey = keyPair!!.publicKey
|
||||||
val hexEncodedPublicKey = keyPair!!.hexEncodedPublicKey
|
val hexEncodedPublicKey = keyPair!!.hexEncodedPublicKey
|
||||||
|
val registrationID = KeyHelper.generateRegistrationId(false)
|
||||||
|
TextSecurePreferences.setLocalRegistrationId(this, registrationID)
|
||||||
DatabaseFactory.getIdentityDatabase(this).saveIdentity(Address.fromSerialized(hexEncodedPublicKey), publicKey,
|
DatabaseFactory.getIdentityDatabase(this).saveIdentity(Address.fromSerialized(hexEncodedPublicKey), publicKey,
|
||||||
IdentityDatabase.VerifiedStatus.VERIFIED, true, System.currentTimeMillis(), true)
|
IdentityDatabase.VerifiedStatus.VERIFIED, true, System.currentTimeMillis(), true)
|
||||||
TextSecurePreferences.setLocalNumber(this, hexEncodedPublicKey)
|
TextSecurePreferences.setLocalNumber(this, hexEncodedPublicKey)
|
||||||
|
Loading…
Reference in New Issue
Block a user