Add new attachmentBackfill capability
This commit is contained in:
parent
6a1f01f876
commit
359cf02161
|
@ -19,6 +19,7 @@ public class DeviceCapabilityUtil {
|
||||||
case DEVICE_CAPABILITY_TRANSFER -> DeviceCapability.TRANSFER;
|
case DEVICE_CAPABILITY_TRANSFER -> DeviceCapability.TRANSFER;
|
||||||
case DEVICE_CAPABILITY_DELETE_SYNC -> DeviceCapability.DELETE_SYNC;
|
case DEVICE_CAPABILITY_DELETE_SYNC -> DeviceCapability.DELETE_SYNC;
|
||||||
case DEVICE_CAPABILITY_STORAGE_SERVICE_RECORD_KEY_ROTATION -> DeviceCapability.STORAGE_SERVICE_RECORD_KEY_ROTATION;
|
case DEVICE_CAPABILITY_STORAGE_SERVICE_RECORD_KEY_ROTATION -> DeviceCapability.STORAGE_SERVICE_RECORD_KEY_ROTATION;
|
||||||
|
case DEVICE_CAPABILITY_ATTACHMENT_BACKFILL -> DeviceCapability.ATTACHMENT_BACKFILL;
|
||||||
case DEVICE_CAPABILITY_UNSPECIFIED, UNRECOGNIZED -> throw Status.INVALID_ARGUMENT.withDescription("Unrecognized device capability").asRuntimeException();
|
case DEVICE_CAPABILITY_UNSPECIFIED, UNRECOGNIZED -> throw Status.INVALID_ARGUMENT.withDescription("Unrecognized device capability").asRuntimeException();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -29,6 +30,7 @@ public class DeviceCapabilityUtil {
|
||||||
case TRANSFER -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_TRANSFER;
|
case TRANSFER -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_TRANSFER;
|
||||||
case DELETE_SYNC -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_DELETE_SYNC;
|
case DELETE_SYNC -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_DELETE_SYNC;
|
||||||
case STORAGE_SERVICE_RECORD_KEY_ROTATION -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_STORAGE_SERVICE_RECORD_KEY_ROTATION;
|
case STORAGE_SERVICE_RECORD_KEY_ROTATION -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_STORAGE_SERVICE_RECORD_KEY_ROTATION;
|
||||||
|
case ATTACHMENT_BACKFILL -> org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_ATTACHMENT_BACKFILL;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,21 @@ public enum DeviceCapability {
|
||||||
STORAGE("storage", AccountCapabilityMode.ANY_DEVICE, false, false),
|
STORAGE("storage", AccountCapabilityMode.ANY_DEVICE, false, false),
|
||||||
TRANSFER("transfer", AccountCapabilityMode.PRIMARY_DEVICE, false, false),
|
TRANSFER("transfer", AccountCapabilityMode.PRIMARY_DEVICE, false, false),
|
||||||
DELETE_SYNC("deleteSync", AccountCapabilityMode.ALL_DEVICES, true, true),
|
DELETE_SYNC("deleteSync", AccountCapabilityMode.ALL_DEVICES, true, true),
|
||||||
STORAGE_SERVICE_RECORD_KEY_ROTATION("ssre2", AccountCapabilityMode.ALL_DEVICES, true, true);
|
STORAGE_SERVICE_RECORD_KEY_ROTATION("ssre2", AccountCapabilityMode.ALL_DEVICES, true, true),
|
||||||
|
ATTACHMENT_BACKFILL("attachmentBackfill", AccountCapabilityMode.PRIMARY_DEVICE, false, true);
|
||||||
|
|
||||||
public enum AccountCapabilityMode {
|
public enum AccountCapabilityMode {
|
||||||
|
/**
|
||||||
|
* The account will have the capability iff the primary device has the capability
|
||||||
|
*/
|
||||||
PRIMARY_DEVICE,
|
PRIMARY_DEVICE,
|
||||||
|
/**
|
||||||
|
* The account will have the capability iff any device on the account has the capability
|
||||||
|
*/
|
||||||
ANY_DEVICE,
|
ANY_DEVICE,
|
||||||
|
/**
|
||||||
|
* The account will have the capability iff all devices on the account have the capability
|
||||||
|
*/
|
||||||
ALL_DEVICES,
|
ALL_DEVICES,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +34,18 @@ public enum DeviceCapability {
|
||||||
private final boolean preventDowngrade;
|
private final boolean preventDowngrade;
|
||||||
private final boolean includeInProfile;
|
private final boolean includeInProfile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a DeviceCapability
|
||||||
|
*
|
||||||
|
* @param name The name of the device capability that clients will see
|
||||||
|
* @param accountCapabilityMode How to combine the constituent device's capabilities in the account to an overall
|
||||||
|
* account capability
|
||||||
|
* @param preventDowngrade If true, don't let linked devices join that don't have a device capability if the
|
||||||
|
* overall account has the capability. Most of the time this should only be used in
|
||||||
|
* conjunction with AccountCapabilityMode.ALL_DEVICES
|
||||||
|
* @param includeInProfile Whether to return this capability on the account's profile. If false, the capability
|
||||||
|
* is only visible to the server
|
||||||
|
*/
|
||||||
DeviceCapability(final String name,
|
DeviceCapability(final String name,
|
||||||
final AccountCapabilityMode accountCapabilityMode,
|
final AccountCapabilityMode accountCapabilityMode,
|
||||||
final boolean preventDowngrade,
|
final boolean preventDowngrade,
|
||||||
|
|
|
@ -100,6 +100,7 @@ enum DeviceCapability {
|
||||||
DEVICE_CAPABILITY_DELETE_SYNC = 3;
|
DEVICE_CAPABILITY_DELETE_SYNC = 3;
|
||||||
reserved 4;
|
reserved 4;
|
||||||
DEVICE_CAPABILITY_STORAGE_SERVICE_RECORD_KEY_ROTATION = 5;
|
DEVICE_CAPABILITY_STORAGE_SERVICE_RECORD_KEY_ROTATION = 5;
|
||||||
|
DEVICE_CAPABILITY_ATTACHMENT_BACKFILL = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ZkCredential {
|
message ZkCredential {
|
||||||
|
|
|
@ -442,8 +442,10 @@ class ProfileControllerTest {
|
||||||
|
|
||||||
@CartesianTest
|
@CartesianTest
|
||||||
void testProfileCapabilities(
|
void testProfileCapabilities(
|
||||||
@CartesianTest.Values(booleans = {true, false}) final boolean isDeleteSyncSupported) {
|
@CartesianTest.Values(booleans = {true, false}) final boolean isDeleteSyncSupported,
|
||||||
|
@CartesianTest.Values(booleans = {true, false}) final boolean isAttachmentBackfillSupported) {
|
||||||
when(capabilitiesAccount.hasCapability(DeviceCapability.DELETE_SYNC)).thenReturn(isDeleteSyncSupported);
|
when(capabilitiesAccount.hasCapability(DeviceCapability.DELETE_SYNC)).thenReturn(isDeleteSyncSupported);
|
||||||
|
when(capabilitiesAccount.hasCapability(DeviceCapability.ATTACHMENT_BACKFILL)).thenReturn(isAttachmentBackfillSupported);
|
||||||
final BaseProfileResponse profile = resources.getJerseyTest()
|
final BaseProfileResponse profile = resources.getJerseyTest()
|
||||||
.target("/v1/profile/" + AuthHelper.VALID_UUID)
|
.target("/v1/profile/" + AuthHelper.VALID_UUID)
|
||||||
.request()
|
.request()
|
||||||
|
@ -451,6 +453,7 @@ class ProfileControllerTest {
|
||||||
.get(BaseProfileResponse.class);
|
.get(BaseProfileResponse.class);
|
||||||
|
|
||||||
assertEquals(isDeleteSyncSupported, profile.getCapabilities().get("deleteSync"));
|
assertEquals(isDeleteSyncSupported, profile.getCapabilities().get("deleteSync"));
|
||||||
|
assertEquals(isAttachmentBackfillSupported, profile.getCapabilities().get("attachmentBackfill"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -434,7 +434,8 @@ class DevicesGrpcServiceTest extends SimpleBaseGrpcTest<DevicesGrpcService, Devi
|
||||||
@CartesianTest.Values(bytes = {Device.PRIMARY_ID, Device.PRIMARY_ID + 1}) final byte deviceId,
|
@CartesianTest.Values(bytes = {Device.PRIMARY_ID, Device.PRIMARY_ID + 1}) final byte deviceId,
|
||||||
@CartesianTest.Values(booleans = {true, false}) final boolean storage,
|
@CartesianTest.Values(booleans = {true, false}) final boolean storage,
|
||||||
@CartesianTest.Values(booleans = {true, false}) final boolean transfer,
|
@CartesianTest.Values(booleans = {true, false}) final boolean transfer,
|
||||||
@CartesianTest.Values(booleans = {true, false}) final boolean deleteSync) {
|
@CartesianTest.Values(booleans = {true, false}) final boolean deleteSync,
|
||||||
|
@CartesianTest.Values(booleans = {true, false}) final boolean attachmentBackfill) {
|
||||||
|
|
||||||
mockAuthenticationInterceptor().setAuthenticatedDevice(AUTHENTICATED_ACI, deviceId);
|
mockAuthenticationInterceptor().setAuthenticatedDevice(AUTHENTICATED_ACI, deviceId);
|
||||||
|
|
||||||
|
@ -455,6 +456,10 @@ class DevicesGrpcServiceTest extends SimpleBaseGrpcTest<DevicesGrpcService, Devi
|
||||||
requestBuilder.addCapabilities(org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_DELETE_SYNC);
|
requestBuilder.addCapabilities(org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_DELETE_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attachmentBackfill) {
|
||||||
|
requestBuilder.addCapabilities(org.signal.chat.common.DeviceCapability.DEVICE_CAPABILITY_ATTACHMENT_BACKFILL);
|
||||||
|
}
|
||||||
|
|
||||||
final SetCapabilitiesResponse ignored = authenticatedServiceStub().setCapabilities(requestBuilder.build());
|
final SetCapabilitiesResponse ignored = authenticatedServiceStub().setCapabilities(requestBuilder.build());
|
||||||
|
|
||||||
final Set<DeviceCapability> expectedCapabilities = new HashSet<>();
|
final Set<DeviceCapability> expectedCapabilities = new HashSet<>();
|
||||||
|
@ -471,6 +476,10 @@ class DevicesGrpcServiceTest extends SimpleBaseGrpcTest<DevicesGrpcService, Devi
|
||||||
expectedCapabilities.add(DeviceCapability.DELETE_SYNC);
|
expectedCapabilities.add(DeviceCapability.DELETE_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attachmentBackfill) {
|
||||||
|
expectedCapabilities.add(DeviceCapability.ATTACHMENT_BACKFILL);
|
||||||
|
}
|
||||||
|
|
||||||
verify(device).setCapabilities(expectedCapabilities);
|
verify(device).setCapabilities(expectedCapabilities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue