Support serviceId based safety number for scannable safety numbers

This commit is contained in:
AsamK 2023-10-06 21:42:28 +02:00
parent 04de0010b5
commit 54c3b19052

View file

@ -58,22 +58,25 @@ public class IdentityHelper {
} }
public String computeSafetyNumber(ServiceId serviceId, IdentityKey theirIdentityKey) { public String computeSafetyNumber(ServiceId serviceId, IdentityKey theirIdentityKey) {
final Fingerprint fingerprint = computeSafetyNumberFingerprint(serviceId, theirIdentityKey); final var fingerprint = computeSafetyNumberFingerprint(serviceId, theirIdentityKey, false);
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) {
final Fingerprint fingerprint = computeSafetyNumberFingerprint(serviceId, theirIdentityKey); var fingerprint = computeSafetyNumberFingerprint(serviceId, theirIdentityKey, false);
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 final ServiceId serviceId, final IdentityKey theirIdentityKey, boolean useServiceId
) { ) {
final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId); final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId);
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId); final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
if (false) { if (useServiceId) {
if (serviceId.isUnknown()) { if (serviceId.isUnknown()) {
return null; return null;
} }