package org.asamk.signal.manager.helper;
+import com.google.protobuf.InvalidProtocolBufferException;
+
import org.asamk.signal.manager.SignalDependencies;
import org.asamk.signal.manager.config.ServiceConfig;
import org.asamk.signal.manager.storage.SignalAccount;
import org.whispersystems.signalservice.api.push.exceptions.NotFoundException;
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
import org.whispersystems.signalservice.api.services.ProfileService;
+import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import java.io.File;
import java.io.IOException;
: avatar.isPresent()
? AvatarUploadParams.forAvatar(streamDetails)
: AvatarUploadParams.unchanged(false);
+ final var paymentsAddress = Optional.ofNullable(newProfile.getPaymentAddress()).map(data -> {
+ try {
+ return SignalServiceProtos.PaymentAddress.parseFrom(data);
+ } catch (InvalidProtocolBufferException e) {
+ return null;
+ }
+ });
final var avatarPath = dependencies.getAccountManager()
.setVersionedProfile(account.getAci(),
account.getProfileKey(),
newProfile.getInternalServiceName(),
newProfile.getAbout() == null ? "" : newProfile.getAbout(),
newProfile.getAboutEmoji() == null ? "" : newProfile.getAboutEmoji(),
- Optional.empty(),
+ paymentsAddress,
avatarUploadParams,
List.of(/* TODO */));
builder.withAvatarUrlPath(avatarPath.orElse(null));
profile.getAbout(),
profile.getAboutEmoji(),
null,
+ null,
profile.isUnrestrictedUnidentifiedAccess()
? Profile.UnidentifiedAccessMode.UNRESTRICTED
: profile.getUnidentifiedAccess() != null
private final String avatarUrlPath;
+ private final byte[] paymentAddress;
+
private final UnidentifiedAccessMode unidentifiedAccessMode;
private final Set<Capability> capabilities;
final String about,
final String aboutEmoji,
final String avatarUrlPath,
+ final byte[] paymentAddress,
final UnidentifiedAccessMode unidentifiedAccessMode,
final Set<Capability> capabilities
) {
this.about = about;
this.aboutEmoji = aboutEmoji;
this.avatarUrlPath = avatarUrlPath;
+ this.paymentAddress = paymentAddress;
this.unidentifiedAccessMode = unidentifiedAccessMode;
this.capabilities = capabilities;
}
about = builder.about;
aboutEmoji = builder.aboutEmoji;
avatarUrlPath = builder.avatarUrlPath;
+ paymentAddress = builder.paymentAddress;
unidentifiedAccessMode = builder.unidentifiedAccessMode;
capabilities = builder.capabilities;
}
builder.about = copy.getAbout();
builder.aboutEmoji = copy.getAboutEmoji();
builder.avatarUrlPath = copy.getAvatarUrlPath();
+ builder.paymentAddress = copy.getPaymentAddress();
builder.unidentifiedAccessMode = copy.getUnidentifiedAccessMode();
builder.capabilities = copy.getCapabilities();
return builder;
return avatarUrlPath;
}
+ public byte[] getPaymentAddress() {
+ return paymentAddress;
+ }
+
public UnidentifiedAccessMode getUnidentifiedAccessMode() {
return unidentifiedAccessMode;
}
private String about;
private String aboutEmoji;
private String avatarUrlPath;
+ private byte[] paymentAddress;
private UnidentifiedAccessMode unidentifiedAccessMode = UnidentifiedAccessMode.UNKNOWN;
private Set<Capability> capabilities = Collections.emptySet();
private long lastUpdateTimestamp = 0;
lastUpdateTimestamp = val;
return this;
}
+
+ public Builder withPaymentAddress(final byte[] val) {
+ paymentAddress = val;
+ return this;
+ }
}
}
r.profile.about,
r.profile.aboutEmoji,
r.profile.avatarUrlPath,
+ r.profile.paymentAddress == null
+ ? null
+ : Base64.getDecoder().decode(r.profile.paymentAddress),
Profile.UnidentifiedAccessMode.valueOfOrUnknown(r.profile.unidentifiedAccessMode),
r.profile.capabilities.stream()
.map(Profile.Capability::valueOfOrNull)
final var base64 = Base64.getEncoder();
var storage = new Storage(recipients.entrySet().stream().map(pair -> {
final var recipient = pair.getValue();
- final var contact = recipient.getContact() == null
+ final var recipientContact = recipient.getContact();
+ final var contact = recipientContact == null
? null
- : new Storage.Recipient.Contact(recipient.getContact().getName(),
- recipient.getContact().getColor(),
- recipient.getContact().getMessageExpirationTime(),
- recipient.getContact().isBlocked(),
- recipient.getContact().isArchived());
- final var profile = recipient.getProfile() == null
+ : new Storage.Recipient.Contact(recipientContact.getName(),
+ recipientContact.getColor(),
+ recipientContact.getMessageExpirationTime(),
+ recipientContact.isBlocked(),
+ recipientContact.isArchived());
+ final var recipientProfile = recipient.getProfile();
+ final var profile = recipientProfile == null
? null
- : new Storage.Recipient.Profile(recipient.getProfile().getLastUpdateTimestamp(),
- recipient.getProfile().getGivenName(),
- recipient.getProfile().getFamilyName(),
- recipient.getProfile().getAbout(),
- recipient.getProfile().getAboutEmoji(),
- recipient.getProfile().getAvatarUrlPath(),
- recipient.getProfile().getUnidentifiedAccessMode().name(),
- recipient.getProfile()
- .getCapabilities()
- .stream()
- .map(Enum::name)
- .collect(Collectors.toSet()));
+ : new Storage.Recipient.Profile(recipientProfile.getLastUpdateTimestamp(),
+ recipientProfile.getGivenName(),
+ recipientProfile.getFamilyName(),
+ recipientProfile.getAbout(),
+ recipientProfile.getAboutEmoji(),
+ recipientProfile.getAvatarUrlPath(),
+ recipientProfile.getPaymentAddress() == null
+ ? null
+ : base64.encodeToString(recipientProfile.getPaymentAddress()),
+ recipientProfile.getUnidentifiedAccessMode().name(),
+ recipientProfile.getCapabilities().stream().map(Enum::name).collect(Collectors.toSet()));
return new Storage.Recipient(pair.getKey().id(),
recipient.getAddress().number().orElse(null),
recipient.getAddress().uuid().map(UUID::toString).orElse(null),
String about,
String aboutEmoji,
String avatarUrlPath,
+ String paymentAddress,
String unidentifiedAccessMode,
Set<String> capabilities
) {}
about,
aboutEmoji,
encryptedProfile.getAvatar(),
+ encryptedProfile.getPaymentAddress(),
getUnidentifiedAccessMode(encryptedProfile, profileCipher),
getCapabilities(encryptedProfile));
} catch (InvalidCiphertextException e) {