import org.signal.libsignal.zkgroup.profiles.ProfileKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.whispersystems.signalservice.api.NetworkResultUtil;
import org.whispersystems.signalservice.api.crypto.SealedSenderAccess;
import org.whispersystems.signalservice.api.profiles.AvatarUploadParams;
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
: avatar == null ? AvatarUploadParams.unchanged(true) : AvatarUploadParams.unchanged(false);
final var paymentsAddress = Optional.ofNullable(newProfile.getMobileCoinAddress())
.map(address -> PaymentUtils.signPaymentsAddress(address,
- account.getAciIdentityKeyPair().getPrivateKey()));
+ account.getAciIdentityKeyPair().getPrivateKey()))
+ .orElse(null);
logger.debug("Uploading new profile");
- final var avatarPath = dependencies.getAccountManager()
+ final var avatarPath = NetworkResultUtil.toSetProfileLegacy(dependencies.getProfileApi()
.setVersionedProfile(account.getAci(),
account.getProfileKey(),
newProfile.getInternalServiceName(),
avatarUploadParams,
List.of(/* TODO implement support for badges */),
account.getConfigurationStore().getPhoneNumberSharingMode()
- == PhoneNumberSharingMode.EVERYBODY);
+ == PhoneNumberSharingMode.EVERYBODY));
if (!avatarUploadParams.keepTheSame) {
- builder.withAvatarUrlPath(avatarPath.orElse(null));
+ builder.withAvatarUrlPath(avatarPath);
}
newProfile = builder.build();
}
final var profile = account.getProfileStore().getProfile(recipientId);
- if (recipientId.equals(account.getSelfRecipientId())) {
- final var isUnrestricted = encryptedProfile.isUnrestrictedUnidentifiedAccess();
- if (account.isUnrestrictedUnidentifiedAccess() != isUnrestricted) {
- account.setUnrestrictedUnidentifiedAccess(isUnrestricted);
- }
- }
-
Profile newProfile = null;
if (profileKey.isPresent()) {
logger.trace("Decrypting profile");
.build();
}
+ if (recipientId.equals(account.getSelfRecipientId())) {
+ final var isUnrestricted = encryptedProfile.isUnrestrictedUnidentifiedAccess();
+ if (account.isUnrestrictedUnidentifiedAccess() != isUnrestricted) {
+ account.setUnrestrictedUnidentifiedAccess(isUnrestricted);
+ }
+ if (account.isPrimaryDevice() && profile != null && newProfile.getCapabilities()
+ .contains(Profile.Capability.storageServiceEncryptionV2Capability) && !profile.getCapabilities()
+ .contains(Profile.Capability.storageServiceEncryptionV2Capability)) {
+ context.getJobExecutor().enqueueJob(new SyncStorageJob(true));
+ }
+ }
+
try {
logger.trace("Storing identity");
final var identityKey = new IdentityKey(Base64.getDecoder().decode(encryptedProfile.getIdentityKey()));