mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Fix contact sync caused decryption lock to never release.
Fix message
This commit is contained in:
parent
7c4e7f261d
commit
5c1ec4c06d
@ -14,6 +14,7 @@ import android.util.Pair;
|
||||
|
||||
import com.annimon.stream.Collectors;
|
||||
import com.annimon.stream.Stream;
|
||||
import com.google.android.gms.common.util.IOUtils;
|
||||
|
||||
import org.signal.libsignal.metadata.InvalidMetadataMessageException;
|
||||
import org.signal.libsignal.metadata.InvalidMetadataVersionException;
|
||||
@ -139,6 +140,7 @@ import org.whispersystems.signalservice.loki.messaging.LokiThreadSessionResetSta
|
||||
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
@ -649,10 +651,12 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
private void handleSynchronizeContactMessage(@NonNull ContactsMessage contactsMessage) {
|
||||
if (contactsMessage.getContactsStream().isStream()) {
|
||||
Log.d("Loki", "Received contact sync message");
|
||||
|
||||
try {
|
||||
DeviceContactsInputStream contactsInputStream = new DeviceContactsInputStream(contactsMessage.getContactsStream().asStream().getInputStream());
|
||||
DeviceContact deviceContact = contactsInputStream.read();
|
||||
while (deviceContact != null) {
|
||||
InputStream in = contactsMessage.getContactsStream().asStream().getInputStream();
|
||||
DeviceContactsInputStream contactsInputStream = new DeviceContactsInputStream(in);
|
||||
List<DeviceContact> devices = contactsInputStream.readAll();
|
||||
for (DeviceContact deviceContact : devices) {
|
||||
// Check if we have the contact as a friend and that we're not trying to sync our own device
|
||||
Address address = Address.fromSerialized(deviceContact.getNumber());
|
||||
if (!address.isPhone() || address.toPhoneString().equalsIgnoreCase(TextSecurePreferences.getLocalNumber(context))) { continue; }
|
||||
@ -676,17 +680,11 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
// TODO: Handle blocked - If user is not blocked then we should do the friend request logic otherwise add them to our block list
|
||||
// TODO: Handle expiration timer - Update expiration timer?
|
||||
// TODO: Handle avatar - Download and set avatar?
|
||||
|
||||
// Read the next contact
|
||||
deviceContact = contactsInputStream.read();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Exception is thrown when we don't have any more contacts to read from
|
||||
} catch (Exception e) {
|
||||
Log.d("Loki", "Failed to sync contact: " + e.getMessage());
|
||||
Log.d("Loki", "Failed to sync contact: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleSynchronizeSentMessage(@NonNull SignalServiceContent content,
|
||||
|
@ -115,7 +115,7 @@ public class MessageSender {
|
||||
if (friendRequestStatus == LokiThreadFriendRequestStatus.FRIENDS || friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_RECEIVED) {
|
||||
sendBackgroundMessage(context, device);
|
||||
} else if (friendRequestStatus == LokiThreadFriendRequestStatus.NONE || friendRequestStatus == LokiThreadFriendRequestStatus.REQUEST_EXPIRED) {
|
||||
sendBackgroundFriendRequest(context, device, "This is a friend request from android! please replace this message in the future");
|
||||
sendBackgroundFriendRequest(context, device, "Accept this friend request to enable messages to be synced across devices");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user