diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java index 869d6b843..45a82a312 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/ProfileController.java @@ -168,7 +168,6 @@ public class ProfileController { @ApiResponse(responseCode = "400", description = "Invalid create profile request.") @ApiResponse(responseCode = "401", description = "Account authentication check failed.") @ApiResponse(responseCode = "403", description = "The request contained a payment address, but payments are not supported in the region of the account’s phone number or the caller's ASN if the account does not have a phone number.") - @ApiResponse(responseCode = "412", description = "The requesting account has the profiles_v2 capability") @ApiResponse(responseCode = "422", description = "Invalid request format") @ManagedAsync public Response setProfile(@Auth AuthenticatedDevice auth, @@ -178,10 +177,6 @@ public class ProfileController { final Account account = accountsManager.getByAccountIdentifier(auth.accountIdentifier()) .orElseThrow(() -> new WebApplicationException(Response.Status.UNAUTHORIZED)); - if (account.hasCapability(DeviceCapability.PROFILES_V2)) { - return Response.status(Response.Status.PRECONDITION_FAILED).build(); - } - final Optional currentProfile = profilesManager.getV1(auth.accountIdentifier(), request.version()); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/DeviceCapabilityUtil.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/DeviceCapabilityUtil.java index 29d12abac..728cc771a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/DeviceCapabilityUtil.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/DeviceCapabilityUtil.java @@ -18,7 +18,6 @@ public class DeviceCapabilityUtil { case DEVICE_CAPABILITY_TRANSFER -> DeviceCapability.TRANSFER; case DEVICE_CAPABILITY_ATTACHMENT_BACKFILL -> DeviceCapability.ATTACHMENT_BACKFILL; case DEVICE_CAPABILITY_SPARSE_POST_QUANTUM_RATCHET -> DeviceCapability.SPARSE_POST_QUANTUM_RATCHET; - case DEVICE_CAPABILITY_PROFILES_V2 -> DeviceCapability.PROFILES_V2; case DEVICE_CAPABILITY_USERNAME_CHANGE_SYNC_MESSAGE -> DeviceCapability.USERNAME_CHANGE_SYNC_MESSAGE; case DEVICE_CAPABILITY_OPTIONAL_PHONE_NUMBER -> DeviceCapability.OPTIONAL_PHONE_NUMBER; case DEVICE_CAPABILITY_REPLY_PRIVATELY -> DeviceCapability.REPLY_PRIVATELY; @@ -35,7 +34,6 @@ public class DeviceCapabilityUtil { case TRANSFER -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_TRANSFER; case ATTACHMENT_BACKFILL -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_ATTACHMENT_BACKFILL; case SPARSE_POST_QUANTUM_RATCHET -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_SPARSE_POST_QUANTUM_RATCHET; - case PROFILES_V2 -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_PROFILES_V2; case USERNAME_CHANGE_SYNC_MESSAGE -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_USERNAME_CHANGE_SYNC_MESSAGE; case OPTIONAL_PHONE_NUMBER -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_OPTIONAL_PHONE_NUMBER; case REPLY_PRIVATELY -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_REPLY_PRIVATELY; diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcHelper.java b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcHelper.java index 432e0cc91..0078ab372 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcHelper.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/grpc/ProfileGrpcHelper.java @@ -33,7 +33,6 @@ import org.whispersystems.textsecuregcm.auth.UnidentifiedAccessChecksum; import org.whispersystems.textsecuregcm.badges.ProfileBadgeConverter; import org.whispersystems.textsecuregcm.s3.PostPolicyGenerator; import org.whispersystems.textsecuregcm.storage.Account; -import org.whispersystems.textsecuregcm.storage.DeviceCapability; import org.whispersystems.textsecuregcm.storage.ProfilesManager; import org.whispersystems.textsecuregcm.storage.VersionedProfile; import org.whispersystems.textsecuregcm.storage.VersionedProfileV1; @@ -97,9 +96,7 @@ public class ProfileGrpcHelper { final ProfileBadgeConverter profileBadgeConverter, final byte[] requestVersion) { - final Optional maybeProfile = account.hasCapability(DeviceCapability.PROFILES_V2) - ? profilesManager.get(account.getAccountIdentifier(), requestVersion) - : Optional.empty(); + final Optional maybeProfile = profilesManager.get(account.getAccountIdentifier(), requestVersion); if (maybeProfile.isEmpty()) { return Optional.empty(); } @@ -141,14 +138,8 @@ public class ProfileGrpcHelper { final ProfilesManager profilesManager, final ServerZkProfileOperations zkProfileOperations) { - final Optional versionedProfile; - if (account.hasCapability(DeviceCapability.PROFILES_V2)) { - versionedProfile = profilesManager.get(account.getAccountIdentifier(), version); - } else { - versionedProfile = Optional.empty(); - } - - return versionedProfile.map(VersionedProfile::commitment) + return profilesManager.get(account.getAccountIdentifier(), version) + .map(VersionedProfile::commitment) .or(() -> profilesManager.getV1(account.getAccountIdentifier(), HexFormat.of().formatHex(version)) .map(VersionedProfileV1::commitment)) .map(commitment -> { @@ -157,7 +148,8 @@ public class ProfileGrpcHelper { try { profileKeyCredentialResponse = ProfileHelper.getExpiringProfileKeyCredential( new ProfileKeyCredentialRequest(encodedCredentialRequest), - new ProfileKeyCommitment(commitment), new ServiceId.Aci(account.getAccountIdentifier()), zkProfileOperations); + new ProfileKeyCommitment(commitment), new ServiceId.Aci(account.getAccountIdentifier()), + zkProfileOperations); } catch (VerificationFailedException | InvalidInputException e) { throw GrpcExceptions.invalidArguments("invalid credential request"); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/DeviceCapability.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/DeviceCapability.java index 06d66685f..766e9e91f 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/DeviceCapability.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/DeviceCapability.java @@ -17,7 +17,6 @@ public enum DeviceCapability { TRANSFER("transfer", AccountCapabilityMode.PRIMARY_DEVICE, AccountCapabilityVisibility.SERVER, false, false), ATTACHMENT_BACKFILL("attachmentBackfill", AccountCapabilityMode.PRIMARY_DEVICE, AccountCapabilityVisibility.SELF, false, false), SPARSE_POST_QUANTUM_RATCHET("spqr", AccountCapabilityMode.ALL_DEVICES, AccountCapabilityVisibility.PUBLIC, true, true), - PROFILES_V2("profiles_v2", AccountCapabilityMode.ALL_DEVICES, AccountCapabilityVisibility.SELF, false, false), USERNAME_CHANGE_SYNC_MESSAGE("usernameChangeSyncMessage", AccountCapabilityMode.ALL_DEVICES, AccountCapabilityVisibility.SELF, true, false), OPTIONAL_PHONE_NUMBER("optionalPhoneNumber", AccountCapabilityMode.ALL_DEVICES, AccountCapabilityVisibility.SERVER, false, false), REPLY_PRIVATELY("replyPrivately", AccountCapabilityMode.ALL_DEVICES, AccountCapabilityVisibility.PUBLIC, false, false), diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/ProfilesManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/ProfilesManager.java index eb8f61580..81c4298d3 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/ProfilesManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/ProfilesManager.java @@ -102,11 +102,7 @@ public class ProfilesManager { redisSet(uuid, null, versionedProfile); try { - // until the PROFILES_V2 capability prevents downgrades, if a client sets a v2 profile, and then the account - // downgrades to v1, all v2 profiles are stale - assert !DeviceCapability.PROFILES_V2.preventDowngrade(); - - profilesV2.deleteAll(uuid); + profilesV2.deleteAll(uuid).join(); } catch (final Exception e) { logger.warn("Failed to delete v2 profile data: {}", uuid, e); } diff --git a/service/src/main/proto/org/signal/chat/common.proto b/service/src/main/proto/org/signal/chat/common.proto index b99403688..112bc6a2a 100644 --- a/service/src/main/proto/org/signal/chat/common.proto +++ b/service/src/main/proto/org/signal/chat/common.proto @@ -90,7 +90,7 @@ enum DeviceCapability { reserved 5; DEVICE_CAPABILITY_ATTACHMENT_BACKFILL = 6; DEVICE_CAPABILITY_SPARSE_POST_QUANTUM_RATCHET = 7; - DEVICE_CAPABILITY_PROFILES_V2 = 8; + reserved 8; DEVICE_CAPABILITY_USERNAME_CHANGE_SYNC_MESSAGE = 9; DEVICE_CAPABILITY_OPTIONAL_PHONE_NUMBER = 10; DEVICE_CAPABILITY_REPLY_PRIVATELY = 11; diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcServiceTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcServiceTest.java index afc5695de..957fd44bd 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcServiceTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ProfileAnonymousGrpcServiceTest.java @@ -98,7 +98,6 @@ import org.whispersystems.textsecuregcm.limits.RateLimiters; import org.whispersystems.textsecuregcm.s3.PostPolicyGenerator; import org.whispersystems.textsecuregcm.storage.Account; import org.whispersystems.textsecuregcm.storage.AccountsManager; -import org.whispersystems.textsecuregcm.storage.DeviceCapability; import org.whispersystems.textsecuregcm.storage.ProfilesManager; import org.whispersystems.textsecuregcm.storage.VersionedProfile; import org.whispersystems.textsecuregcm.storage.VersionedProfileV1; @@ -264,7 +263,6 @@ public class ProfileAnonymousGrpcServiceTest extends SimpleBaseGrpcTest