Use safety numbers with ACI by default

This commit is contained in:
AsamK 2023-11-05 11:59:09 +01:00
parent 506dcfa6c0
commit 8d423adb4d

View file

@ -57,33 +57,28 @@ public class IdentityHelper {
} }
public String computeSafetyNumber(ServiceId serviceId, IdentityKey theirIdentityKey) { public String computeSafetyNumber(ServiceId serviceId, IdentityKey theirIdentityKey) {
final var fingerprint = computeSafetyNumberFingerprint(serviceId, theirIdentityKey, false); final var fingerprint = computeSafetyNumberFingerprint(serviceId, theirIdentityKey);
return fingerprint == null ? null : fingerprint.getDisplayableFingerprint().getDisplayText(); return fingerprint == null ? null : fingerprint.getDisplayableFingerprint().getDisplayText();
} }
public ScannableFingerprint computeSafetyNumberForScanning(ServiceId serviceId, IdentityKey theirIdentityKey) { public ScannableFingerprint computeSafetyNumberForScanning(ServiceId serviceId, IdentityKey theirIdentityKey) {
var fingerprint = computeSafetyNumberFingerprint(serviceId, theirIdentityKey, false); var fingerprint = computeSafetyNumberFingerprint(serviceId, theirIdentityKey);
if (fingerprint == null) {
fingerprint = computeSafetyNumberFingerprint(serviceId, theirIdentityKey, true);
}
return fingerprint == null ? null : fingerprint.getScannableFingerprint(); return fingerprint == null ? null : fingerprint.getScannableFingerprint();
} }
private Fingerprint computeSafetyNumberFingerprint( private Fingerprint computeSafetyNumberFingerprint(
final ServiceId serviceId, final IdentityKey theirIdentityKey, boolean useServiceId final ServiceId serviceId, final IdentityKey theirIdentityKey
) { ) {
final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId); if (!serviceId.isUnknown()) {
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
if (useServiceId) {
if (serviceId.isUnknown()) {
return null;
}
return Utils.computeSafetyNumberForUuid(account.getAci(), return Utils.computeSafetyNumberForUuid(account.getAci(),
account.getAciIdentityKeyPair().getPublicKey(), account.getAciIdentityKeyPair().getPublicKey(),
serviceId, serviceId,
theirIdentityKey); theirIdentityKey);
} }
final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId);
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
if (address.number().isEmpty()) { if (address.number().isEmpty()) {
return null; return null;
} }