Retire fully-adopted device capabilities

This commit is contained in:
Jon Chambers
2023-08-07 12:28:29 -04:00
committed by Jon Chambers
parent ae61ee5486
commit d868e3075c
10 changed files with 55 additions and 374 deletions

View File

@@ -32,9 +32,6 @@ public class BaseAccountAuthenticator {
private static final String AUTHENTICATION_SUCCEEDED_TAG_NAME = "succeeded";
private static final String AUTHENTICATION_FAILURE_REASON_TAG_NAME = "reason";
private static final String ENABLED_TAG_NAME = "enabled";
private static final String AUTHENTICATION_HAS_STORY_CAPABILITY = "hasStoryCapability";
private static final String STORY_ADOPTION_COUNTER_NAME = name(BaseAccountAuthenticator.class, "storyAdoption");
private static final String DAYS_SINCE_LAST_SEEN_DISTRIBUTION_NAME = name(BaseAccountAuthenticator.class, "daysSinceLastSeen");
private static final String IS_PRIMARY_DEVICE_TAG = "isPrimary";
@@ -75,7 +72,6 @@ public class BaseAccountAuthenticator {
public Optional<AuthenticatedAccount> authenticate(BasicCredentials basicCredentials, boolean enabledRequired) {
boolean succeeded = false;
String failureReason = null;
boolean hasStoryCapability = false;
try {
final UUID accountUuid;
@@ -94,8 +90,6 @@ public class BaseAccountAuthenticator {
return Optional.empty();
}
hasStoryCapability = account.map(Account::isStoriesSupported).orElse(false);
Optional<Device> device = account.get().getDevice(deviceId);
if (device.isEmpty()) {
@@ -150,9 +144,6 @@ public class BaseAccountAuthenticator {
}
Metrics.counter(AUTHENTICATION_COUNTER_NAME, tags).increment();
Tags storyTags = Tags.of(AUTHENTICATION_HAS_STORY_CAPABILITY, String.valueOf(hasStoryCapability));
Metrics.counter(STORY_ADOPTION_COUNTER_NAME, storyTags).increment();
}
}

View File

@@ -344,16 +344,7 @@ public class DeviceController {
}
static boolean isCapabilityDowngrade(Account account, DeviceCapabilities capabilities) {
boolean isDowngrade = false;
isDowngrade |= account.isStoriesSupported() && !capabilities.isStories();
isDowngrade |= account.isPniSupported() && !capabilities.isPni();
isDowngrade |= account.isChangeNumberSupported() && !capabilities.isChangeNumber();
isDowngrade |= account.isAnnouncementGroupSupported() && !capabilities.isAnnouncementGroup();
isDowngrade |= account.isSenderKeySupported() && !capabilities.isSenderKey();
isDowngrade |= account.isGiftBadgesSupported() && !capabilities.isGiftBadges();
return isDowngrade;
return account.isPniSupported() && !capabilities.isPni();
}
private Pair<Account, Device> createDevice(final String password,

View File

@@ -9,11 +9,23 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.whispersystems.textsecuregcm.storage.Account;
public record UserCapabilities(
@JsonProperty("gv1-migration") boolean gv1Migration,
@Deprecated(forRemoval = true)
@JsonProperty("gv1-migration")
boolean gv1Migration,
@Deprecated(forRemoval = true)
boolean senderKey,
@Deprecated(forRemoval = true)
boolean announcementGroup,
@Deprecated(forRemoval = true)
boolean changeNumber,
@Deprecated(forRemoval = true)
boolean stories,
@Deprecated(forRemoval = true)
boolean giftBadges,
boolean paymentActivation,
boolean pni) {
@@ -21,11 +33,11 @@ public record UserCapabilities(
public static UserCapabilities createForAccount(Account account) {
return new UserCapabilities(
true,
account.isSenderKeySupported(),
account.isAnnouncementGroupSupported(),
account.isChangeNumberSupported(),
account.isStoriesSupported(),
account.isGiftBadgesSupported(),
true,
true,
true,
true,
true,
// Hardcode payment activation flag to false until all clients support the flow
false,

View File

@@ -256,34 +256,10 @@ public class Account {
return getMasterDevice().map(Device::getCapabilities).map(Device.DeviceCapabilities::isTransfer).orElse(false);
}
public boolean isSenderKeySupported() {
return allEnabledDevicesHaveCapability(DeviceCapabilities::isSenderKey);
}
public boolean isAnnouncementGroupSupported() {
return allEnabledDevicesHaveCapability(DeviceCapabilities::isAnnouncementGroup);
}
public boolean isChangeNumberSupported() {
return allEnabledDevicesHaveCapability(DeviceCapabilities::isChangeNumber);
}
public boolean isPniSupported() {
return allEnabledDevicesHaveCapability(DeviceCapabilities::isPni);
}
public boolean isStoriesSupported() {
requireNotStale();
return devices.stream()
.filter(Device::isEnabled)
.allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isStories());
}
public boolean isGiftBadgesSupported() {
return allEnabledDevicesHaveCapability(DeviceCapabilities::isGiftBadges);
}
public boolean isPaymentActivationSupported() {
return allEnabledDevicesHaveCapability(DeviceCapabilities::isPaymentActivation);
}

View File

@@ -281,41 +281,19 @@ public class Device {
@JsonProperty
private boolean transfer;
@JsonProperty
private boolean senderKey;
@JsonProperty
private boolean announcementGroup;
@JsonProperty
private boolean changeNumber;
@JsonProperty
private boolean pni;
@JsonProperty
private boolean stories;
@JsonProperty
private boolean giftBadges;
@JsonProperty
private boolean paymentActivation;
public DeviceCapabilities() {
}
public DeviceCapabilities(boolean storage, boolean transfer,
final boolean senderKey, final boolean announcementGroup, final boolean changeNumber,
final boolean pni, final boolean stories, final boolean giftBadges, final boolean paymentActivation) {
public DeviceCapabilities(boolean storage, boolean transfer, final boolean pni, final boolean paymentActivation) {
this.storage = storage;
this.transfer = transfer;
this.senderKey = senderKey;
this.announcementGroup = announcementGroup;
this.changeNumber = changeNumber;
this.pni = pni;
this.stories = stories;
this.giftBadges = giftBadges;
this.paymentActivation = paymentActivation;
}
@@ -327,30 +305,10 @@ public class Device {
return transfer;
}
public boolean isSenderKey() {
return senderKey;
}
public boolean isAnnouncementGroup() {
return announcementGroup;
}
public boolean isChangeNumber() {
return changeNumber;
}
public boolean isPni() {
return pni;
}
public boolean isStories() {
return stories;
}
public boolean isGiftBadges() {
return giftBadges;
}
public boolean isPaymentActivation() {
return paymentActivation;
}