mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-02 06:33:38 +01:00
Fix issue with PNIs in contact sync.
This commit is contained in:
@@ -8,13 +8,16 @@ package org.whispersystems.signalservice.api.messages.multidevice;
|
||||
|
||||
import org.signal.libsignal.zkgroup.profiles.ProfileKey;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class DeviceContact {
|
||||
|
||||
private final SignalServiceAddress address;
|
||||
private final Optional<ACI> aci;
|
||||
private final Optional<String> e164;
|
||||
private final Optional<String> name;
|
||||
private final Optional<SignalServiceAttachmentStream> avatar;
|
||||
private final Optional<String> color;
|
||||
@@ -25,7 +28,8 @@ public class DeviceContact {
|
||||
private final Optional<Integer> inboxPosition;
|
||||
private final boolean archived;
|
||||
|
||||
public DeviceContact(SignalServiceAddress address,
|
||||
public DeviceContact(Optional<ACI> aci,
|
||||
Optional<String> e164,
|
||||
Optional<String> name,
|
||||
Optional<SignalServiceAttachmentStream> avatar,
|
||||
Optional<String> color,
|
||||
@@ -36,7 +40,12 @@ public class DeviceContact {
|
||||
Optional<Integer> inboxPosition,
|
||||
boolean archived)
|
||||
{
|
||||
this.address = address;
|
||||
if (aci.isEmpty() && e164.isEmpty()) {
|
||||
throw new IllegalArgumentException("Must have either ACI or E164");
|
||||
}
|
||||
|
||||
this.aci = aci;
|
||||
this.e164 = e164;
|
||||
this.name = name;
|
||||
this.avatar = avatar;
|
||||
this.color = color;
|
||||
@@ -56,8 +65,12 @@ public class DeviceContact {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SignalServiceAddress getAddress() {
|
||||
return address;
|
||||
public Optional<ACI> getAci() {
|
||||
return aci;
|
||||
}
|
||||
|
||||
public Optional<String> getE164() {
|
||||
return e164;
|
||||
}
|
||||
|
||||
public Optional<String> getColor() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.signal.libsignal.zkgroup.InvalidInputException;
|
||||
import org.signal.libsignal.zkgroup.profiles.ProfileKey;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.internal.push.ContactDetails;
|
||||
import org.whispersystems.signalservice.internal.util.Util;
|
||||
@@ -45,7 +46,8 @@ public class DeviceContactsInputStream extends ChunkedInputStream {
|
||||
throw new IOException("Missing contact address!");
|
||||
}
|
||||
|
||||
SignalServiceAddress address = new SignalServiceAddress(ServiceId.parseOrThrow(details.aci), details.number);
|
||||
Optional<ACI> aci = Optional.ofNullable(ACI.parseOrNull(details.aci));
|
||||
Optional<String> e164 = Optional.ofNullable(details.number);
|
||||
Optional<String> name = Optional.ofNullable(details.name);
|
||||
Optional<SignalServiceAttachmentStream> avatar = Optional.empty();
|
||||
Optional<String> color = details.color != null ? Optional.of(details.color) : Optional.empty();
|
||||
@@ -108,7 +110,7 @@ public class DeviceContactsInputStream extends ChunkedInputStream {
|
||||
blocked = details.blocked;
|
||||
archived = details.archived;
|
||||
|
||||
return new DeviceContact(address, name, avatar, color, verified, profileKey, blocked, expireTimer, inboxPosition, archived);
|
||||
return new DeviceContact(aci, e164, name, avatar, color, verified, profileKey, blocked, expireTimer, inboxPosition, archived);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,10 +38,12 @@ public class DeviceContactsOutputStream extends ChunkedOutputStream {
|
||||
private void writeContactDetails(DeviceContact contact) throws IOException {
|
||||
ContactDetails.Builder contactDetails = new ContactDetails.Builder();
|
||||
|
||||
contactDetails.aci(contact.getAddress().getServiceId().toString());
|
||||
if (contact.getAci().isPresent()) {
|
||||
contactDetails.aci(contact.getAci().get().toString());
|
||||
}
|
||||
|
||||
if (contact.getAddress().getNumber().isPresent()) {
|
||||
contactDetails.number(contact.getAddress().getNumber().get());
|
||||
if (contact.getE164().isPresent()) {
|
||||
contactDetails.number(contact.getE164().get());
|
||||
}
|
||||
|
||||
if (contact.getName().isPresent()) {
|
||||
|
||||
Reference in New Issue
Block a user