mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-09-28 07:51:42 +01:00
Allow numberless accounts to do KT self-checks.
This commit is contained in:
@@ -102,8 +102,11 @@ class CheckKeyTransparencyJob private constructor(
|
||||
} else if (SignalStore.account.usernameSyncState != AccountValues.UsernameSyncState.IN_SYNC || SignalStore.account.usernameSyncErrorCount > 0) {
|
||||
Log.i(TAG, "Username is in a bad state. Exiting.")
|
||||
false
|
||||
} else if (!Recipient.self().hasAci || !Recipient.self().hasE164) {
|
||||
Log.i(TAG, "Missing an ACI or E164. Exiting.")
|
||||
} else if (!Recipient.self().hasAci) {
|
||||
Log.i(TAG, "Missing an ACI. Exiting.")
|
||||
false
|
||||
} else if (!Recipient.self().hasE164 && SignalStore.account.pni != null) {
|
||||
Log.i(TAG, "Missing an E164 for an account that should have one. Exiting.")
|
||||
false
|
||||
} else {
|
||||
true
|
||||
@@ -127,18 +130,20 @@ class CheckKeyTransparencyJob private constructor(
|
||||
SignalStore.misc.nextKeyTransparencyTime = System.currentTimeMillis() + TIME_BETWEEN_CHECK.inWholeMilliseconds + getRandomDelay(maxHours = 8)
|
||||
|
||||
val recipient = SignalDatabase.recipients.getRecord(Recipient.self().id)
|
||||
val e164 = recipient.e164
|
||||
val usernameHash = SignalStore.account.username?.let { Username(it).hash }.takeIf { Recipient.self().usernameSyncMessagesCapability.isSupported }
|
||||
|
||||
val result = SignalNetwork.keyTransparencyApi.check(
|
||||
checkMode = CheckMode.Self(isE164Discoverable = SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode == PhoneNumberDiscoverabilityMode.DISCOVERABLE),
|
||||
checkMode = CheckMode.Self(isE164Discoverable = e164 != null && SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode == PhoneNumberDiscoverabilityMode.DISCOVERABLE),
|
||||
aci = recipient.aci!!.libSignalAci,
|
||||
aciIdentityKey = SignalStore.account.aciIdentityKey.publicKey,
|
||||
e164 = recipient.e164!!,
|
||||
unidentifiedAccessKey = ProfileKeyUtil.profileKeyOrNull(recipient.profileKey).let { UnidentifiedAccess.deriveAccessKeyFrom(it) },
|
||||
usernameHash = SignalStore.account.username?.let { Username(it).hash }.takeIf { Recipient.self().usernameSyncMessagesCapability.isSupported },
|
||||
e164 = e164,
|
||||
unidentifiedAccessKey = e164?.let { ProfileKeyUtil.profileKeyOrNull(recipient.profileKey).let { profileKey -> UnidentifiedAccess.deriveAccessKeyFrom(profileKey) } },
|
||||
usernameHash = usernameHash,
|
||||
keyTransparencyStore = KeyTransparencyStore
|
||||
)
|
||||
|
||||
Log.i(TAG, "Key transparency complete, result: $result. Included username in check: ${Recipient.self().usernameSyncMessagesCapability.isSupported}, discoverability: ${SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode}, next check time: ${SignalStore.misc.nextKeyTransparencyTime}")
|
||||
Log.i(TAG, "Key transparency complete, result: $result. Included E164 in check: ${e164 != null}, included username in check: ${usernameHash != null}, discoverability: ${SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode}, next check time: ${SignalStore.misc.nextKeyTransparencyTime}")
|
||||
return when (result) {
|
||||
is RequestResult.Success -> {
|
||||
SignalStore.misc.hasKeyTransparencyFailure = false
|
||||
|
||||
Reference in New Issue
Block a user