Add batch identity checks to stories and share/forward flows.

This commit is contained in:
Cody Henthorne
2022-07-26 16:31:55 -04:00
parent 87cb2d6bf8
commit a7a5f2e8c6
9 changed files with 418 additions and 24 deletions

View File

@@ -112,7 +112,7 @@ public final class ProfileService {
.onErrorReturn(ServiceResponse::forUnknownError);
}
public @NonNull Single<ServiceResponse<IdentityCheckResponse>> performIdentityCheck(@Nonnull Map<ServiceId, IdentityKey> aciIdentityKeyMap, @Nonnull Optional<UnidentifiedAccess> unidentifiedAccess) {
public @NonNull Single<ServiceResponse<IdentityCheckResponse>> performIdentityCheck(@Nonnull Map<ServiceId, IdentityKey> aciIdentityKeyMap) {
List<AciFingerprintPair> aciKeyPairs = aciIdentityKeyMap.entrySet()
.stream()
.map(e -> new AciFingerprintPair(e.getKey(), e.getValue()))
@@ -129,9 +129,9 @@ public final class ProfileService {
ResponseMapper<IdentityCheckResponse> responseMapper = DefaultResponseMapper.getDefault(IdentityCheckResponse.class);
return signalWebSocket.request(builder.build(), unidentifiedAccess)
return signalWebSocket.request(builder.build(), Optional.empty())
.map(responseMapper::map)
.onErrorResumeNext(t -> performIdentityCheckRestFallback(request, unidentifiedAccess, responseMapper))
.onErrorResumeNext(t -> performIdentityCheckRestFallback(request, Optional.empty(), responseMapper))
.onErrorReturn(ServiceResponse::forUnknownError);
}

View File

@@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.signal.libsignal.protocol.IdentityKey;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.internal.util.JsonUtil;
import java.util.List;
@@ -16,6 +16,13 @@ public class IdentityCheckResponse {
@JsonProperty("elements")
private List<AciIdentityPair> aciKeyPairs;
public IdentityCheckResponse() {}
// Visible for testing
public IdentityCheckResponse(List<AciIdentityPair> aciKeyPairs) {
this.aciKeyPairs = aciKeyPairs;
}
public @Nullable List<AciIdentityPair> getAciKeyPairs() {
return aciKeyPairs;
}
@@ -23,14 +30,22 @@ public class IdentityCheckResponse {
public static final class AciIdentityPair {
@JsonProperty
@JsonDeserialize(using = JsonUtil.ServiceIdDeserializer.class)
private ServiceId aci;
@JsonDeserialize(using = JsonUtil.AciDeserializer.class)
private ACI aci;
@JsonProperty
@JsonDeserialize(using = JsonUtil.IdentityKeyDeserializer.class)
private IdentityKey identityKey;
public @Nullable ServiceId getAci() {
public AciIdentityPair() {}
// Visible for testing
public AciIdentityPair(ACI aci, IdentityKey identityKey) {
this.aci = aci;
this.identityKey = identityKey;
}
public @Nullable ACI getAci() {
return aci;
}