Improve ServiceId parsing functions.

This commit is contained in:
Greyson Parrelli
2023-08-09 14:54:06 -04:00
committed by Alex Hart
parent 784f94ecdb
commit 6d2d3ae528
7 changed files with 162 additions and 20 deletions

View File

@@ -4154,7 +4154,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
return RecipientRecord(
id = recipientId,
aci = ACI.parseOrNull(cursor.requireString(ACI_COLUMN)),
pni = PNI.parseOrNull(cursor.requireString(PNI_COLUMN)),
pni = PNI.parsePrefixedOrNull(cursor.requireString(PNI_COLUMN)),
username = cursor.requireString(USERNAME),
e164 = cursor.requireString(E164),
email = cursor.requireString(EMAIL),

View File

@@ -47,7 +47,7 @@ public class PniMigrationJob extends MigrationJob {
return;
}
PNI pni = PNI.parseUnPrefixedOrNull(ApplicationDependencies.getSignalServiceAccountManager().getWhoAmI().getPni());
PNI pni = PNI.parseOrNull(ApplicationDependencies.getSignalServiceAccountManager().getWhoAmI().getPni());
if (pni == null) {
throw new IOException("Invalid PNI!");

View File

@@ -129,7 +129,7 @@ public final class RegistrationRepository {
Preconditions.checkNotNull(response.getPniPreKeyCollection(), "Missing PNI prekey collection!");
ACI aci = ACI.parseOrThrow(response.getVerifyAccountResponse().getUuid());
PNI pni = PNI.parseUnPrefixedOrThrow(response.getVerifyAccountResponse().getPni());
PNI pni = PNI.parseOrThrow(response.getVerifyAccountResponse().getPni());
boolean hasPin = response.getVerifyAccountResponse().isStorageCapable();
SignalStore.account().setAci(aci);