Support for advertising payment addresses on profile

This commit is contained in:
Moxie Marlinspike
2020-04-02 12:45:24 -07:00
parent 3432529f9c
commit 95f0ce1816
10 changed files with 221 additions and 22 deletions

View File

@@ -21,6 +21,9 @@ import com.google.common.annotations.VisibleForTesting;
import org.hibernate.validator.constraints.Length;
import org.whispersystems.textsecuregcm.storage.Device;
import org.whispersystems.textsecuregcm.storage.Device.DeviceCapabilities;
import org.whispersystems.textsecuregcm.storage.PaymentAddress;
import java.util.List;
public class AccountAttributes {
@@ -49,6 +52,9 @@ public class AccountAttributes {
@JsonProperty
private boolean unrestrictedUnidentifiedAccess;
@JsonProperty
private List<PaymentAddress> payments;
@JsonProperty
private DeviceCapabilities capabilities;
@@ -56,17 +62,18 @@ public class AccountAttributes {
@VisibleForTesting
public AccountAttributes(String signalingKey, boolean fetchesMessages, int registrationId, String pin) {
this(signalingKey, fetchesMessages, registrationId, null, pin, null);
this(signalingKey, fetchesMessages, registrationId, null, pin, null, null);
}
@VisibleForTesting
public AccountAttributes(String signalingKey, boolean fetchesMessages, int registrationId, String name, String pin, String registrationLock) {
public AccountAttributes(String signalingKey, boolean fetchesMessages, int registrationId, String name, String pin, String registrationLock, List<PaymentAddress> payments) {
this.signalingKey = signalingKey;
this.fetchesMessages = fetchesMessages;
this.registrationId = registrationId;
this.name = name;
this.pin = pin;
this.registrationLock = registrationLock;
this.payments = payments;
}
public String getSignalingKey() {
@@ -104,4 +111,8 @@ public class AccountAttributes {
public DeviceCapabilities getCapabilities() {
return capabilities;
}
public List<PaymentAddress> getPayments() {
return payments;
}
}

View File

@@ -6,7 +6,9 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.annotations.VisibleForTesting;
import org.signal.zkgroup.profiles.ProfileKeyCredentialResponse;
import org.whispersystems.textsecuregcm.storage.PaymentAddress;
import java.util.List;
import java.util.UUID;
public class Profile {
@@ -35,6 +37,9 @@ public class Profile {
@JsonProperty
private UUID uuid;
@JsonProperty
private List<PaymentAddress> payments;
@JsonProperty
@JsonSerialize(using = ProfileKeyCredentialResponseAdapter.Serializing.class)
@JsonDeserialize(using = ProfileKeyCredentialResponseAdapter.Deserializing.class)
@@ -45,7 +50,8 @@ public class Profile {
public Profile(String name, String avatar, String identityKey,
String unidentifiedAccess, boolean unrestrictedUnidentifiedAccess,
UserCapabilities capabilities, String username, UUID uuid,
ProfileKeyCredentialResponse credential)
ProfileKeyCredentialResponse credential,
List<PaymentAddress> payments)
{
this.name = name;
this.avatar = avatar;
@@ -55,6 +61,7 @@ public class Profile {
this.capabilities = capabilities;
this.username = username;
this.uuid = uuid;
this.payments = payments;
this.credential = credential;
}
@@ -97,4 +104,9 @@ public class Profile {
public UUID getUuid() {
return uuid;
}
@VisibleForTesting
public List<PaymentAddress> getPayments() {
return payments;
}
}