mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Merge pull request #87 from loki-project/security
Don't Include an Auth Token with Encrypted File Uploads
This commit is contained in:
commit
98d4ee1724
@ -6,6 +6,7 @@
|
|||||||
<domain includeSubdomains="true">storage.seed1.loki.network</domain>
|
<domain includeSubdomains="true">storage.seed1.loki.network</domain>
|
||||||
<domain includeSubdomains="true">storage.seed2.loki.network</domain>
|
<domain includeSubdomains="true">storage.seed2.loki.network</domain>
|
||||||
<domain includeSubdomains="true">public.loki.foundation:22023</domain>
|
<domain includeSubdomains="true">public.loki.foundation:22023</domain>
|
||||||
|
<domain includeSubdomains="true">file-dev.lokinet.org</domain>
|
||||||
<domain includeSubdomains="true">127.0.0.1</domain>
|
<domain includeSubdomains="true">127.0.0.1</domain>
|
||||||
</domain-config>
|
</domain-config>
|
||||||
</network-security-config>
|
</network-security-config>
|
@ -103,7 +103,7 @@ import org.whispersystems.signalservice.loki.api.LokiP2PAPIDelegate;
|
|||||||
import org.whispersystems.signalservice.loki.api.LokiPublicChat;
|
import org.whispersystems.signalservice.loki.api.LokiPublicChat;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPublicChatAPI;
|
import org.whispersystems.signalservice.loki.api.LokiPublicChatAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiRSSFeed;
|
import org.whispersystems.signalservice.loki.api.LokiRSSFeed;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -188,7 +188,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
LokiDotNetAPI.setCache(new Cache(this.getCacheDir(), OK_HTTP_CACHE_SIZE));
|
LokiDotNetAPI.setCache(new Cache(this.getCacheDir(), OK_HTTP_CACHE_SIZE));
|
||||||
// Loki - Update device mappings
|
// Loki - Update device mappings
|
||||||
if (setUpStorageAPIIfNeeded()) {
|
if (setUpStorageAPIIfNeeded()) {
|
||||||
LokiStorageAPI.Companion.getShared().updateUserDeviceMappings();
|
LokiFileServerAPI.Companion.getShared().updateUserDeviceMappings();
|
||||||
if (TextSecurePreferences.needsRevocationCheck(this)) {
|
if (TextSecurePreferences.needsRevocationCheck(this)) {
|
||||||
checkNeedsRevocation();
|
checkNeedsRevocation();
|
||||||
}
|
}
|
||||||
@ -466,7 +466,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
boolean isDebugMode = BuildConfig.DEBUG;
|
boolean isDebugMode = BuildConfig.DEBUG;
|
||||||
byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize();
|
byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize();
|
||||||
LokiAPIDatabaseProtocol database = DatabaseFactory.getLokiAPIDatabase(this);
|
LokiAPIDatabaseProtocol database = DatabaseFactory.getLokiAPIDatabase(this);
|
||||||
LokiStorageAPI.Companion.configure(isDebugMode, userHexEncodedPublicKey, userPrivateKey, database);
|
LokiFileServerAPI.Companion.configure(isDebugMode, userHexEncodedPublicKey, userPrivateKey, database);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -59,7 +59,7 @@ import org.whispersystems.signalservice.api.crypto.ProfileCipher;
|
|||||||
import org.whispersystems.signalservice.api.util.StreamDetails;
|
import org.whispersystems.signalservice.api.util.StreamDetails;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiDotNetAPI;
|
import org.whispersystems.signalservice.loki.api.LokiDotNetAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPublicChatAPI;
|
import org.whispersystems.signalservice.loki.api.LokiPublicChatAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -407,7 +407,7 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
|
|||||||
//Loki - Upload the profile photo here
|
//Loki - Upload the profile photo here
|
||||||
if (avatar != null) {
|
if (avatar != null) {
|
||||||
Log.d("Loki", "Start uploading profile photo");
|
Log.d("Loki", "Start uploading profile photo");
|
||||||
LokiStorageAPI storageAPI = LokiStorageAPI.shared;
|
LokiFileServerAPI storageAPI = LokiFileServerAPI.shared;
|
||||||
LokiDotNetAPI.UploadResult result = storageAPI.uploadProfilePicture(storageAPI.getServer(), profileKey, avatar);
|
LokiDotNetAPI.UploadResult result = storageAPI.uploadProfilePicture(storageAPI.getServer(), profileKey, avatar);
|
||||||
Log.d("Loki", "Profile photo uploaded, the url is " + result.getUrl());
|
Log.d("Loki", "Profile photo uploaded, the url is " + result.getUrl());
|
||||||
TextSecurePreferences.setProfileAvatarUrl(context, result.getUrl());
|
TextSecurePreferences.setProfileAvatarUrl(context, result.getUrl());
|
||||||
|
@ -12,7 +12,7 @@ import org.thoughtcrime.securesms.jobs.TypingSendJob;
|
|||||||
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -83,7 +83,7 @@ public class TypingStatusSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendTyping(long threadId, boolean typingStarted) {
|
private void sendTyping(long threadId, boolean typingStarted) {
|
||||||
LokiStorageAPI storageAPI = LokiStorageAPI.Companion.getShared();
|
LokiFileServerAPI storageAPI = LokiFileServerAPI.Companion.getShared();
|
||||||
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context);
|
||||||
Recipient recipient = threadDatabase.getRecipientForThreadId(threadId);
|
Recipient recipient = threadDatabase.getRecipientForThreadId(threadId);
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public class TypingStatusSender {
|
|||||||
ApplicationContext.getInstance(context).getJobManager().add(new TypingSendJob(threadId, typingStarted));
|
ApplicationContext.getInstance(context).getJobManager().add(new TypingSendJob(threadId, typingStarted));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LokiStorageAPI.shared.getAllDevicePublicKeys(recipient.getAddress().serialize()).success(devices -> {
|
LokiFileServerAPI.shared.getAllDevicePublicKeys(recipient.getAddress().serialize()).success(devices -> {
|
||||||
for (String device : devices) {
|
for (String device : devices) {
|
||||||
Recipient deviceRecipient = Recipient.from(context, Address.fromSerialized(device), false);
|
Recipient deviceRecipient = Recipient.from(context, Address.fromSerialized(device), false);
|
||||||
long deviceThreadID = threadDatabase.getThreadIdIfExistsFor(deviceRecipient);
|
long deviceThreadID = threadDatabase.getThreadIdIfExistsFor(deviceRecipient);
|
||||||
|
@ -234,7 +234,7 @@ import org.whispersystems.libsignal.InvalidMessageException;
|
|||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPI;
|
import org.whispersystems.signalservice.loki.api.LokiAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPublicChat;
|
import org.whispersystems.signalservice.loki.api.LokiPublicChat;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.PairingAuthorisation;
|
import org.whispersystems.signalservice.loki.api.PairingAuthorisation;
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus;
|
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus;
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
|
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
|
||||||
@ -2290,7 +2290,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
if (threadID != this.threadId) {
|
if (threadID != this.threadId) {
|
||||||
Recipient threadRecipient = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadID);
|
Recipient threadRecipient = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadID);
|
||||||
if (threadRecipient != null && !threadRecipient.isGroupRecipient()) {
|
if (threadRecipient != null && !threadRecipient.isGroupRecipient()) {
|
||||||
LokiStorageAPI.shared.getAllDevicePublicKeys(threadRecipient.getAddress().serialize()).success(devices -> {
|
LokiFileServerAPI.shared.getAllDevicePublicKeys(threadRecipient.getAddress().serialize()).success(devices -> {
|
||||||
// We should update our input if this thread is a part of the other threads device
|
// We should update our input if this thread is a part of the other threads device
|
||||||
if (devices.contains(recipient.getAddress().serialize())) {
|
if (devices.contains(recipient.getAddress().serialize())) {
|
||||||
this.updateInputPanel();
|
this.updateInputPanel();
|
||||||
|
@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.logging.Log;
|
|||||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities;
|
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities;
|
||||||
import org.thoughtcrime.securesms.util.AsyncLoader;
|
import org.thoughtcrime.securesms.util.AsyncLoader;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec;
|
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -33,7 +33,7 @@ public class DeviceListLoader extends AsyncLoader<List<Device>> {
|
|||||||
public List<Device> loadInBackground() {
|
public List<Device> loadInBackground() {
|
||||||
try {
|
try {
|
||||||
String ourPublicKey = TextSecurePreferences.getLocalNumber(getContext());
|
String ourPublicKey = TextSecurePreferences.getLocalNumber(getContext());
|
||||||
List<String> secondaryDevicePublicKeys = LokiStorageAPI.shared.getSecondaryDevicePublicKeys(ourPublicKey).get();
|
List<String> secondaryDevicePublicKeys = LokiFileServerAPI.shared.getSecondaryDevicePublicKeys(ourPublicKey).get();
|
||||||
List<Device> devices = Stream.of(secondaryDevicePublicKeys).map(this::mapToDevice).toList();
|
List<Device> devices = Stream.of(secondaryDevicePublicKeys).map(this::mapToDevice).toList();
|
||||||
Collections.sort(devices, new DeviceComparator());
|
Collections.sort(devices, new DeviceComparator());
|
||||||
return devices;
|
return devices;
|
||||||
|
@ -36,7 +36,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
|||||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup.Type;
|
import org.whispersystems.signalservice.api.messages.SignalServiceGroup.Type;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -318,7 +318,7 @@ public class GroupMessageProcessor {
|
|||||||
try {
|
try {
|
||||||
String masterHexEncodedPublicKey = hexEncodedPublicKey.equalsIgnoreCase(ourPublicKey)
|
String masterHexEncodedPublicKey = hexEncodedPublicKey.equalsIgnoreCase(ourPublicKey)
|
||||||
? TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
? TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||||
: PromiseUtil.timeout(LokiStorageAPI.shared.getPrimaryDevicePublicKey(hexEncodedPublicKey), 5000).get();
|
: PromiseUtil.timeout(LokiFileServerAPI.shared.getPrimaryDevicePublicKey(hexEncodedPublicKey), 5000).get();
|
||||||
return masterHexEncodedPublicKey != null ? masterHexEncodedPublicKey : hexEncodedPublicKey;
|
return masterHexEncodedPublicKey != null ? masterHexEncodedPublicKey : hexEncodedPublicKey;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return hexEncodedPublicKey;
|
return hexEncodedPublicKey;
|
||||||
@ -329,7 +329,7 @@ public class GroupMessageProcessor {
|
|||||||
String ourNumber = TextSecurePreferences.getLocalNumber(context);
|
String ourNumber = TextSecurePreferences.getLocalNumber(context);
|
||||||
for (String member : members) {
|
for (String member : members) {
|
||||||
// Make sure we have session with all of the members secondary devices
|
// Make sure we have session with all of the members secondary devices
|
||||||
LokiStorageAPI.shared.getAllDevicePublicKeys(member).success(devices -> {
|
LokiFileServerAPI.shared.getAllDevicePublicKeys(member).success(devices -> {
|
||||||
if (devices.contains(ourNumber)) { return Unit.INSTANCE; }
|
if (devices.contains(ourNumber)) { return Unit.INSTANCE; }
|
||||||
for (String device : devices) {
|
for (String device : devices) {
|
||||||
SignalProtocolAddress protocolAddress = new SignalProtocolAddress(device, SignalServiceAddress.DEFAULT_DEVICE_ID);
|
SignalProtocolAddress protocolAddress = new SignalProtocolAddress(device, SignalServiceAddress.DEFAULT_DEVICE_ID);
|
||||||
|
@ -27,7 +27,7 @@ import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
|||||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer;
|
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -131,7 +131,7 @@ import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
|||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.loki.api.DeviceLinkingSession;
|
import org.whispersystems.signalservice.loki.api.DeviceLinkingSession;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiAPI;
|
import org.whispersystems.signalservice.loki.api.LokiAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
import org.whispersystems.signalservice.loki.api.PairingAuthorisation;
|
import org.whispersystems.signalservice.loki.api.PairingAuthorisation;
|
||||||
import org.whispersystems.signalservice.loki.crypto.LokiServiceCipher;
|
import org.whispersystems.signalservice.loki.crypto.LokiServiceCipher;
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus;
|
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus;
|
||||||
@ -1177,7 +1177,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
// Send a background message to the primary device
|
// Send a background message to the primary device
|
||||||
MessageSender.sendBackgroundMessage(context, authorisation.getPrimaryDevicePublicKey());
|
MessageSender.sendBackgroundMessage(context, authorisation.getPrimaryDevicePublicKey());
|
||||||
// Propagate the updates to the file server
|
// Propagate the updates to the file server
|
||||||
LokiStorageAPI storageAPI = LokiStorageAPI.Companion.getShared();
|
LokiFileServerAPI storageAPI = LokiFileServerAPI.Companion.getShared();
|
||||||
storageAPI.updateUserDeviceMappings();
|
storageAPI.updateUserDeviceMappings();
|
||||||
// Update display names
|
// Update display names
|
||||||
if (content.senderDisplayName.isPresent() && content.senderDisplayName.get().length() > 0) {
|
if (content.senderDisplayName.isPresent() && content.senderDisplayName.get().length() > 0) {
|
||||||
@ -1245,7 +1245,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
private void handleSessionRequestIfNeeded(@NonNull SignalServiceContent content) {
|
private void handleSessionRequestIfNeeded(@NonNull SignalServiceContent content) {
|
||||||
if (content.isFriendRequest() && isSessionRequest(content)) {
|
if (content.isFriendRequest() && isSessionRequest(content)) {
|
||||||
// Check if the session request from a member in one of our groups or our friend
|
// Check if the session request from a member in one of our groups or our friend
|
||||||
LokiStorageAPI.shared.getPrimaryDevicePublicKey(content.getSender()).success(primaryDevicePublicKey -> {
|
LokiFileServerAPI.shared.getPrimaryDevicePublicKey(content.getSender()).success(primaryDevicePublicKey -> {
|
||||||
String sender = primaryDevicePublicKey != null ? primaryDevicePublicKey : content.getSender();
|
String sender = primaryDevicePublicKey != null ? primaryDevicePublicKey : content.getSender();
|
||||||
long threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(Recipient.from(context, Address.fromSerialized(sender), false));
|
long threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(Recipient.from(context, Address.fromSerialized(sender), false));
|
||||||
LokiThreadFriendRequestStatus threadFriendRequestStatus = DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadID);
|
LokiThreadFriendRequestStatus threadFriendRequestStatus = DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadID);
|
||||||
@ -1284,7 +1284,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
// Allow profile sharing with contact
|
// Allow profile sharing with contact
|
||||||
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(contactID, true);
|
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(contactID, true);
|
||||||
// Update the last message if needed
|
// Update the last message if needed
|
||||||
LokiStorageAPI.shared.getPrimaryDevicePublicKey(pubKey).success(primaryDevice -> {
|
LokiFileServerAPI.shared.getPrimaryDevicePublicKey(pubKey).success(primaryDevice -> {
|
||||||
Util.runOnMain(() -> {
|
Util.runOnMain(() -> {
|
||||||
long primaryDeviceThreadID = primaryDevice == null ? threadID : DatabaseFactory.getThreadDatabase(context).getThreadIdFor(Recipient.from(context, Address.fromSerialized(primaryDevice), false));
|
long primaryDeviceThreadID = primaryDevice == null ? threadID : DatabaseFactory.getThreadDatabase(context).getThreadIdFor(Recipient.from(context, Address.fromSerialized(primaryDevice), false));
|
||||||
FriendRequestHandler.updateLastFriendRequestMessage(context, primaryDeviceThreadID, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED);
|
FriendRequestHandler.updateLastFriendRequestMessage(context, primaryDeviceThreadID, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED);
|
||||||
@ -1799,7 +1799,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
*/
|
*/
|
||||||
private Recipient getPrimaryDeviceRecipient(String pubKey) {
|
private Recipient getPrimaryDeviceRecipient(String pubKey) {
|
||||||
try {
|
try {
|
||||||
String primaryDevice = PromiseUtil.timeout(LokiStorageAPI.shared.getPrimaryDevicePublicKey(pubKey), 5000).get();
|
String primaryDevice = PromiseUtil.timeout(LokiFileServerAPI.shared.getPrimaryDevicePublicKey(pubKey), 5000).get();
|
||||||
String publicKey = (primaryDevice != null) ? primaryDevice : pubKey;
|
String publicKey = (primaryDevice != null) ? primaryDevice : pubKey;
|
||||||
// If the public key matches our primary device then we need to forward the message to ourselves (Note to self)
|
// If the public key matches our primary device then we need to forward the message to ourselves (Note to self)
|
||||||
String ourPrimaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
String ourPrimaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
|
||||||
|
@ -51,7 +51,7 @@ import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
|||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPublicChat;
|
import org.whispersystems.signalservice.loki.api.LokiPublicChat;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -368,7 +368,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
|||||||
if (!member.isPhone() || member.serialize().equalsIgnoreCase(localNumber)) { continue; }
|
if (!member.isPhone() || member.serialize().equalsIgnoreCase(localNumber)) { continue; }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<String> secondaryDevices = PromiseUtil.timeout(LokiStorageAPI.shared.getSecondaryDevicePublicKeys(member.serialize()), 5000).get();
|
List<String> secondaryDevices = PromiseUtil.timeout(LokiFileServerAPI.shared.getSecondaryDevicePublicKeys(member.serialize()), 5000).get();
|
||||||
memberSet.addAll(Stream.of(secondaryDevices).map(string -> {
|
memberSet.addAll(Stream.of(secondaryDevices).map(string -> {
|
||||||
// Loki - Calling .map(Address::fromSerialized) is causing errors, thus we use the long method :(
|
// Loki - Calling .map(Address::fromSerialized) is causing errors, thus we use the long method :(
|
||||||
return Address.fromSerialized(string);
|
return Address.fromSerialized(string);
|
||||||
|
@ -43,7 +43,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSy
|
|||||||
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiSyncMessage;
|
import org.whispersystems.signalservice.loki.messaging.LokiSyncMessage;
|
||||||
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||||||
LokiSyncMessage syncMessage = null;
|
LokiSyncMessage syncMessage = null;
|
||||||
if (shouldSendSyncMessage) {
|
if (shouldSendSyncMessage) {
|
||||||
// Set the sync message destination the primary device, this way it will show that we sent a message to the primary device and not a secondary device
|
// Set the sync message destination the primary device, this way it will show that we sent a message to the primary device and not a secondary device
|
||||||
String primaryDevice = PromiseUtil.get(LokiStorageAPI.shared.getPrimaryDevicePublicKey(address.getNumber()), null);
|
String primaryDevice = PromiseUtil.get(LokiFileServerAPI.shared.getPrimaryDevicePublicKey(address.getNumber()), null);
|
||||||
SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice);
|
SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice);
|
||||||
// We also need to use the original message id and not -1
|
// We also need to use the original message id and not -1
|
||||||
syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId);
|
syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId);
|
||||||
|
@ -30,7 +30,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
|||||||
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiSyncMessage;
|
import org.whispersystems.signalservice.loki.messaging.LokiSyncMessage;
|
||||||
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||||||
LokiSyncMessage syncMessage = null;
|
LokiSyncMessage syncMessage = null;
|
||||||
if (shouldSendSyncMessage) {
|
if (shouldSendSyncMessage) {
|
||||||
// Set the sync message destination to the primary device, this way it will show that we sent a message to the primary device and not a secondary device
|
// Set the sync message destination to the primary device, this way it will show that we sent a message to the primary device and not a secondary device
|
||||||
String primaryDevice = PromiseUtil.get(LokiStorageAPI.shared.getPrimaryDevicePublicKey(address.getNumber()), null);
|
String primaryDevice = PromiseUtil.get(LokiFileServerAPI.shared.getPrimaryDevicePublicKey(address.getNumber()), null);
|
||||||
SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice);
|
SignalServiceAddress primaryAddress = primaryDevice == null ? address : new SignalServiceAddress(primaryDevice);
|
||||||
// We also need to use the original message id and not -1
|
// We also need to use the original message id and not -1
|
||||||
syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId);
|
syncMessage = new LokiSyncMessage(primaryAddress, templateMessageId);
|
||||||
|
@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.sms.MessageSender
|
|||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
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.api.LokiStorageAPI
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI
|
||||||
import org.whispersystems.signalservice.loki.api.PairingAuthorisation
|
import org.whispersystems.signalservice.loki.api.PairingAuthorisation
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
||||||
import org.whispersystems.signalservice.loki.utilities.recover
|
import org.whispersystems.signalservice.loki.utilities.recover
|
||||||
@ -32,12 +32,12 @@ fun checkForRevocation(context: Context) {
|
|||||||
val primaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context) ?: return
|
val primaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context) ?: return
|
||||||
val ourDevice = TextSecurePreferences.getLocalNumber(context)
|
val ourDevice = TextSecurePreferences.getLocalNumber(context)
|
||||||
|
|
||||||
LokiStorageAPI.shared.fetchDeviceMappings(primaryDevice).bind { mappings ->
|
LokiFileServerAPI.shared.fetchDeviceMappings(primaryDevice).bind { mappings ->
|
||||||
val ourMapping = mappings.find { it.secondaryDevicePublicKey == ourDevice }
|
val ourMapping = mappings.find { it.secondaryDevicePublicKey == ourDevice }
|
||||||
if (ourMapping != null) throw Error("Device has not been revoked")
|
if (ourMapping != null) throw Error("Device has not been revoked")
|
||||||
// remove pairing authorisations for our device
|
// remove pairing authorisations for our device
|
||||||
DatabaseFactory.getLokiAPIDatabase(context).removePairingAuthorisations(ourDevice)
|
DatabaseFactory.getLokiAPIDatabase(context).removePairingAuthorisations(ourDevice)
|
||||||
LokiStorageAPI.shared.updateUserDeviceMappings()
|
LokiFileServerAPI.shared.updateUserDeviceMappings()
|
||||||
}.successUi {
|
}.successUi {
|
||||||
TextSecurePreferences.setNeedsRevocationCheck(context, false)
|
TextSecurePreferences.setNeedsRevocationCheck(context, false)
|
||||||
ApplicationContext.getInstance(context).clearData()
|
ApplicationContext.getInstance(context).clearData()
|
||||||
@ -49,7 +49,7 @@ fun checkForRevocation(context: Context) {
|
|||||||
|
|
||||||
fun getAllDeviceFriendRequestStatuses(context: Context, hexEncodedPublicKey: String): Promise<Map<String, LokiThreadFriendRequestStatus>, Exception> {
|
fun getAllDeviceFriendRequestStatuses(context: Context, hexEncodedPublicKey: String): Promise<Map<String, LokiThreadFriendRequestStatus>, Exception> {
|
||||||
val lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context)
|
val lokiThreadDatabase = DatabaseFactory.getLokiThreadDatabase(context)
|
||||||
return LokiStorageAPI.shared.getAllDevicePublicKeys(hexEncodedPublicKey).map { keys ->
|
return LokiFileServerAPI.shared.getAllDevicePublicKeys(hexEncodedPublicKey).map { keys ->
|
||||||
val map = mutableMapOf<String, LokiThreadFriendRequestStatus>()
|
val map = mutableMapOf<String, LokiThreadFriendRequestStatus>()
|
||||||
for (devicePublicKey in keys) {
|
for (devicePublicKey in keys) {
|
||||||
val device = Recipient.from(context, Address.fromSerialized(devicePublicKey), false)
|
val device = Recipient.from(context, Address.fromSerialized(devicePublicKey), false)
|
||||||
@ -63,7 +63,7 @@ fun getAllDeviceFriendRequestStatuses(context: Context, hexEncodedPublicKey: Str
|
|||||||
|
|
||||||
fun getAllDevicePublicKeysWithFriendStatus(context: Context, hexEncodedPublicKey: String): Promise<Map<String, Boolean>, Unit> {
|
fun getAllDevicePublicKeysWithFriendStatus(context: Context, hexEncodedPublicKey: String): Promise<Map<String, Boolean>, Unit> {
|
||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
return LokiStorageAPI.shared.getAllDevicePublicKeys(hexEncodedPublicKey).map { keys ->
|
return LokiFileServerAPI.shared.getAllDevicePublicKeys(hexEncodedPublicKey).map { keys ->
|
||||||
val devices = keys.toMutableSet()
|
val devices = keys.toMutableSet()
|
||||||
if (hexEncodedPublicKey != userHexEncodedPublicKey) {
|
if (hexEncodedPublicKey != userHexEncodedPublicKey) {
|
||||||
devices.remove(userHexEncodedPublicKey)
|
devices.remove(userHexEncodedPublicKey)
|
||||||
@ -92,7 +92,7 @@ fun shouldAutomaticallyBecomeFriendsWithDevice(publicKey: String, context: Conte
|
|||||||
return Promise.of(true)
|
return Promise.of(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return LokiStorageAPI.shared.getPrimaryDevicePublicKey(publicKey).bind { primaryDevicePublicKey ->
|
return LokiFileServerAPI.shared.getPrimaryDevicePublicKey(publicKey).bind { primaryDevicePublicKey ->
|
||||||
// If the public key doesn't have any other devices then go through regular friend request logic
|
// If the public key doesn't have any other devices then go through regular friend request logic
|
||||||
if (primaryDevicePublicKey == null) {
|
if (primaryDevicePublicKey == null) {
|
||||||
return@bind Promise.of(false)
|
return@bind Promise.of(false)
|
||||||
@ -157,7 +157,7 @@ fun signAndSendPairingAuthorisationMessage(context: Context, pairingAuthorisatio
|
|||||||
Log.d("Loki", "Failed to send pairing authorization message to ${address.serialize()}.")
|
Log.d("Loki", "Failed to send pairing authorization message to ${address.serialize()}.")
|
||||||
}
|
}
|
||||||
|
|
||||||
val updatePromise = LokiStorageAPI.shared.updateUserDeviceMappings().fail {
|
val updatePromise = LokiFileServerAPI.shared.updateUserDeviceMappings().fail {
|
||||||
Log.d("Loki", "Failed to update device mapping")
|
Log.d("Loki", "Failed to update device mapping")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ fun isOneOfOurDevices(context: Context, address: Address): Promise<Boolean, Exce
|
|||||||
}
|
}
|
||||||
|
|
||||||
val ourPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val ourPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
return LokiStorageAPI.shared.getAllDevicePublicKeys(ourPublicKey).map { devices ->
|
return LokiFileServerAPI.shared.getAllDevicePublicKeys(ourPublicKey).map { devices ->
|
||||||
devices.contains(address.serialize())
|
devices.contains(address.serialize())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.loki.signAndSendPairingAuthorisationMessage
|
|||||||
import org.thoughtcrime.securesms.sms.MessageSender
|
import org.thoughtcrime.securesms.sms.MessageSender
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.thoughtcrime.securesms.util.Util
|
import org.thoughtcrime.securesms.util.Util
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI
|
||||||
import org.whispersystems.signalservice.loki.api.PairingAuthorisation
|
import org.whispersystems.signalservice.loki.api.PairingAuthorisation
|
||||||
|
|
||||||
class LinkedDevicesActivity : PassphraseRequiredActionBarActivity, LoaderManager.LoaderCallbacks<List<Device>>, DeviceClickListener, EditDeviceNameDialogDelegate, LinkDeviceMasterModeDialogDelegate {
|
class LinkedDevicesActivity : PassphraseRequiredActionBarActivity, LoaderManager.LoaderCallbacks<List<Device>>, DeviceClickListener, EditDeviceNameDialogDelegate, LinkDeviceMasterModeDialogDelegate {
|
||||||
@ -119,7 +119,7 @@ class LinkedDevicesActivity : PassphraseRequiredActionBarActivity, LoaderManager
|
|||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this)
|
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this)
|
||||||
val database = DatabaseFactory.getLokiAPIDatabase(this)
|
val database = DatabaseFactory.getLokiAPIDatabase(this)
|
||||||
database.removePairingAuthorisation(userHexEncodedPublicKey, slaveDeviceHexEncodedPublicKey)
|
database.removePairingAuthorisation(userHexEncodedPublicKey, slaveDeviceHexEncodedPublicKey)
|
||||||
LokiStorageAPI.shared.updateUserDeviceMappings().success {
|
LokiFileServerAPI.shared.updateUserDeviceMappings().success {
|
||||||
MessageSender.sendUnpairRequest(this, slaveDeviceHexEncodedPublicKey)
|
MessageSender.sendUnpairRequest(this, slaveDeviceHexEncodedPublicKey)
|
||||||
}
|
}
|
||||||
LoaderManager.getInstance(this).restartLoader(0, null, this)
|
LoaderManager.getInstance(this).restartLoader(0, null, this)
|
||||||
|
@ -6,7 +6,7 @@ import org.thoughtcrime.securesms.devicelist.Device
|
|||||||
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities
|
import org.thoughtcrime.securesms.loki.redesign.utilities.MnemonicUtilities
|
||||||
import org.thoughtcrime.securesms.util.AsyncLoader
|
import org.thoughtcrime.securesms.util.AsyncLoader
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI
|
||||||
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ class LinkedDevicesLoader(context: Context) : AsyncLoader<List<Device>>(context)
|
|||||||
override fun loadInBackground(): List<Device>? {
|
override fun loadInBackground(): List<Device>? {
|
||||||
try {
|
try {
|
||||||
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
val slaveDeviceHexEncodedPublicKeys = LokiStorageAPI.shared.getSecondaryDevicePublicKeys(userHexEncodedPublicKey).get()
|
val slaveDeviceHexEncodedPublicKeys = LokiFileServerAPI.shared.getSecondaryDevicePublicKeys(userHexEncodedPublicKey).get()
|
||||||
return slaveDeviceHexEncodedPublicKeys.map { hexEncodedPublicKey ->
|
return slaveDeviceHexEncodedPublicKeys.map { hexEncodedPublicKey ->
|
||||||
val shortID = MnemonicUtilities.getFirst3Words(mnemonicCodec, hexEncodedPublicKey)
|
val shortID = MnemonicUtilities.getFirst3Words(mnemonicCodec, hexEncodedPublicKey)
|
||||||
val name = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(hexEncodedPublicKey)
|
val name = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(hexEncodedPublicKey)
|
||||||
|
@ -41,7 +41,7 @@ import org.thoughtcrime.securesms.util.BitmapUtil
|
|||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.signalservice.api.crypto.ProfileCipher
|
import org.whispersystems.signalservice.api.crypto.ProfileCipher
|
||||||
import org.whispersystems.signalservice.api.util.StreamDetails
|
import org.whispersystems.signalservice.api.util.StreamDetails
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
@ -159,7 +159,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
val encodedProfileKey = ProfileKeyUtil.generateEncodedProfileKey(this)
|
val encodedProfileKey = ProfileKeyUtil.generateEncodedProfileKey(this)
|
||||||
val profileKey = ProfileKeyUtil.getProfileKeyFromEncodedString(encodedProfileKey)
|
val profileKey = ProfileKeyUtil.getProfileKeyFromEncodedString(encodedProfileKey)
|
||||||
if (isUpdatingProfilePicture && profilePicture != null) {
|
if (isUpdatingProfilePicture && profilePicture != null) {
|
||||||
val storageAPI = LokiStorageAPI.shared
|
val storageAPI = LokiFileServerAPI.shared
|
||||||
val deferred = deferred<Unit, Exception>()
|
val deferred = deferred<Unit, Exception>()
|
||||||
AsyncTask.execute {
|
AsyncTask.execute {
|
||||||
val stream = StreamDetails(ByteArrayInputStream(profilePicture), "image/jpeg", profilePicture.size.toLong())
|
val stream = StreamDetails(ByteArrayInputStream(profilePicture), "image/jpeg", profilePicture.size.toLong())
|
||||||
|
@ -24,7 +24,7 @@ import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
|||||||
import org.whispersystems.signalservice.loki.api.LokiPublicChat
|
import org.whispersystems.signalservice.loki.api.LokiPublicChat
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPublicChatAPI
|
import org.whispersystems.signalservice.loki.api.LokiPublicChatAPI
|
||||||
import org.whispersystems.signalservice.loki.api.LokiPublicChatMessage
|
import org.whispersystems.signalservice.loki.api.LokiPublicChatMessage
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus
|
||||||
import org.whispersystems.signalservice.loki.utilities.successBackground
|
import org.whispersystems.signalservice.loki.utilities.successBackground
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
@ -156,7 +156,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
|||||||
fun pollForNewMessages() {
|
fun pollForNewMessages() {
|
||||||
fun processIncomingMessage(message: LokiPublicChatMessage) {
|
fun processIncomingMessage(message: LokiPublicChatMessage) {
|
||||||
// If the sender of the current message is not a secondary device, we need to set the display name in the database
|
// If the sender of the current message is not a secondary device, we need to set the display name in the database
|
||||||
val primaryDevice = LokiStorageAPI.shared.getPrimaryDevicePublicKey(message.hexEncodedPublicKey).get()
|
val primaryDevice = LokiFileServerAPI.shared.getPrimaryDevicePublicKey(message.hexEncodedPublicKey).get()
|
||||||
if (primaryDevice == null) {
|
if (primaryDevice == null) {
|
||||||
val senderDisplayName = "${message.displayName} (...${message.hexEncodedPublicKey.takeLast(8)})"
|
val senderDisplayName = "${message.displayName} (...${message.hexEncodedPublicKey.takeLast(8)})"
|
||||||
DatabaseFactory.getLokiUserDatabase(context).setServerDisplayName(group.id, message.hexEncodedPublicKey, senderDisplayName)
|
DatabaseFactory.getLokiUserDatabase(context).setServerDisplayName(group.id, message.hexEncodedPublicKey, senderDisplayName)
|
||||||
@ -219,17 +219,17 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
|||||||
var uniqueDevices = setOf<String>()
|
var uniqueDevices = setOf<String>()
|
||||||
val userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(context).privateKey.serialize()
|
val userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(context).privateKey.serialize()
|
||||||
val database = DatabaseFactory.getLokiAPIDatabase(context)
|
val database = DatabaseFactory.getLokiAPIDatabase(context)
|
||||||
LokiStorageAPI.configure(false, userHexEncodedPublicKey, userPrivateKey, database)
|
LokiFileServerAPI.configure(false, userHexEncodedPublicKey, userPrivateKey, database)
|
||||||
LokiStorageAPI.shared.getAllDevicePublicKeys(userHexEncodedPublicKey).bind { devices ->
|
LokiFileServerAPI.shared.getAllDevicePublicKeys(userHexEncodedPublicKey).bind { devices ->
|
||||||
userDevices = devices
|
userDevices = devices
|
||||||
api.getMessages(group.channel, group.server)
|
api.getMessages(group.channel, group.server)
|
||||||
}.bind { messages ->
|
}.bind { messages ->
|
||||||
if (messages.isNotEmpty()) {
|
if (messages.isNotEmpty()) {
|
||||||
// We need to fetch device mappings for all the devices we don't have
|
// We need to fetch device mappings for all the devices we don't have
|
||||||
uniqueDevices = messages.map { it.hexEncodedPublicKey }.toSet()
|
uniqueDevices = messages.map { it.hexEncodedPublicKey }.toSet()
|
||||||
val devicesToUpdate = uniqueDevices.filter { !userDevices.contains(it) && LokiStorageAPI.shared.hasCacheExpired(it) }
|
val devicesToUpdate = uniqueDevices.filter { !userDevices.contains(it) && LokiFileServerAPI.shared.hasCacheExpired(it) }
|
||||||
if (devicesToUpdate.isNotEmpty()) {
|
if (devicesToUpdate.isNotEmpty()) {
|
||||||
return@bind LokiStorageAPI.shared.getDeviceMappings(devicesToUpdate.toSet()).then { messages }
|
return@bind LokiFileServerAPI.shared.getDeviceMappings(devicesToUpdate.toSet()).then { messages }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Promise.of(messages)
|
Promise.of(messages)
|
||||||
@ -238,7 +238,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
|||||||
val newDisplayNameUpdatees = uniqueDevices.mapNotNull {
|
val newDisplayNameUpdatees = uniqueDevices.mapNotNull {
|
||||||
// This will return null if current device is primary
|
// This will return null if current device is primary
|
||||||
// So if it's non-null then we know the device is a secondary device
|
// So if it's non-null then we know the device is a secondary device
|
||||||
val primaryDevice = LokiStorageAPI.shared.getPrimaryDevicePublicKey(it).get()
|
val primaryDevice = LokiFileServerAPI.shared.getPrimaryDevicePublicKey(it).get()
|
||||||
primaryDevice
|
primaryDevice
|
||||||
}.toSet()
|
}.toSet()
|
||||||
// Fetch the display names of the primary devices
|
// Fetch the display names of the primary devices
|
||||||
|
@ -14,7 +14,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage
|
|||||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup
|
import org.whispersystems.signalservice.api.messages.SignalServiceGroup
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
||||||
import org.whispersystems.signalservice.loki.api.LokiRSSFeed
|
import org.whispersystems.signalservice.loki.api.LokiRSSFeed
|
||||||
import org.whispersystems.signalservice.loki.api.LokiRSSProxy
|
import org.whispersystems.signalservice.loki.api.LokiRSSFeedProxy
|
||||||
import org.whispersystems.signalservice.loki.utilities.successBackground
|
import org.whispersystems.signalservice.loki.utilities.successBackground
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
@ -48,7 +48,7 @@ class LokiRSSFeedPoller(private val context: Context, private val feed: LokiRSSF
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun poll() {
|
private fun poll() {
|
||||||
LokiRSSProxy.fetch(feed.url).successBackground { xml ->
|
LokiRSSFeedProxy.fetch(feed.url).successBackground { xml ->
|
||||||
val items = XMLParser(xml).call()
|
val items = XMLParser(xml).call()
|
||||||
items.reversed().forEach { item ->
|
items.reversed().forEach { item ->
|
||||||
val title = item.title ?: return@forEach
|
val title = item.title ?: return@forEach
|
||||||
|
@ -23,7 +23,7 @@ import org.thoughtcrime.securesms.logging.Log;
|
|||||||
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
||||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -60,7 +60,7 @@ import org.thoughtcrime.securesms.util.Util;
|
|||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||||
import org.whispersystems.signalservice.api.push.ContactTokenDetails;
|
import org.whispersystems.signalservice.api.push.ContactTokenDetails;
|
||||||
import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
|
||||||
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
|
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
|
||||||
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public class MessageSender {
|
|||||||
sendBackgroundMessage(context, contactHexEncodedPublicKey);
|
sendBackgroundMessage(context, contactHexEncodedPublicKey);
|
||||||
|
|
||||||
// Go through the other devices and only send background messages if we're friends or we have received friend request
|
// Go through the other devices and only send background messages if we're friends or we have received friend request
|
||||||
LokiStorageAPI.shared.getAllDevicePublicKeys(contactHexEncodedPublicKey).success(devices -> {
|
LokiFileServerAPI.shared.getAllDevicePublicKeys(contactHexEncodedPublicKey).success(devices -> {
|
||||||
Util.runOnMain(() -> {
|
Util.runOnMain(() -> {
|
||||||
for (String device : devices) {
|
for (String device : devices) {
|
||||||
// Don't send message to the device we already have sent to
|
// Don't send message to the device we already have sent to
|
||||||
@ -234,7 +234,7 @@ public class MessageSender {
|
|||||||
final int ttl) {
|
final int ttl) {
|
||||||
String ourPublicKey = TextSecurePreferences.getLocalNumber(context);
|
String ourPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||||
JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
||||||
LokiStorageAPI.shared.getAllDevicePublicKeys(ourPublicKey).success(devices -> {
|
LokiFileServerAPI.shared.getAllDevicePublicKeys(ourPublicKey).success(devices -> {
|
||||||
Util.runOnMain(() -> {
|
Util.runOnMain(() -> {
|
||||||
for (String device : devices) {
|
for (String device : devices) {
|
||||||
// Don't send to ourselves
|
// Don't send to ourselves
|
||||||
|
Loading…
x
Reference in New Issue
Block a user