Fix PNI prefixing in provisioning message.

This commit is contained in:
Greyson Parrelli
2023-08-09 10:35:54 -04:00
committed by Alex Hart
parent f56a65d30d
commit 1cc7b46555
6 changed files with 17 additions and 31 deletions

View File

@@ -668,7 +668,7 @@ public class SignalServiceAccountManager {
.setPniIdentityKeyPublic(ByteString.copyFrom(pniIdentityKeyPair.getPublicKey().serialize()))
.setPniIdentityKeyPrivate(ByteString.copyFrom(pniIdentityKeyPair.getPrivateKey().serialize()))
.setAci(aci.toString())
.setPni(pni.toString())
.setPni(pni.toStringWithoutPrefix())
.setNumber(e164)
.setProfileKey(ByteString.copyFrom(profileKey.serialize()))
.setProvisioningCode(code)

View File

@@ -182,5 +182,8 @@ sealed class ServiceId(val libSignalServiceId: LibSignalServiceId) {
}
override fun toString(): String = super.toString()
/** String version without the PNI: prefix. This is only for specific proto fields. For application storage, prefer [toString]. */
fun toStringWithoutPrefix(): String = rawUuid.toString()
}
}

View File

@@ -43,7 +43,7 @@ public final class SignalContactRecord implements SignalRecord {
this.proto = proto;
this.hasUnknownFields = ProtoUtil.hasUnknownFields(proto);
this.aci = ACI.parseOrUnknown(proto.getAci());
this.pni = OptionalUtil.absentIfEmpty(proto.getPni()).map(PNI::parseOrNull);
this.pni = OptionalUtil.absentIfEmpty(proto.getPni()).map(PNI::parseUnPrefixedOrNull);
this.e164 = OptionalUtil.absentIfEmpty(proto.getE164());
this.profileGivenName = OptionalUtil.absentIfEmpty(proto.getGivenName());
this.profileFamilyName = OptionalUtil.absentIfEmpty(proto.getFamilyName());
@@ -300,7 +300,7 @@ public final class SignalContactRecord implements SignalRecord {
}
public Builder setPni(PNI pni) {
builder.setPni(pni == null ? "" : pni.toString());
builder.setPni(pni == null ? "" : pni.toStringWithoutPrefix());
return this;
}