Fix update from old versions without PNI

Fixes #1032
This commit is contained in:
AsamK 2022-10-07 12:04:22 +02:00
parent cf0110ab95
commit 9a4693136d
2 changed files with 5 additions and 1 deletions

View file

@ -9,6 +9,7 @@ import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.PinLockedException;
import org.asamk.signal.manager.config.ServiceConfig;
import org.asamk.signal.manager.storage.SignalAccount;
import org.asamk.signal.manager.util.KeyUtils;
import org.asamk.signal.manager.util.NumberVerificationUtils;
import org.signal.libsignal.protocol.InvalidKeyException;
import org.slf4j.Logger;
@ -99,6 +100,9 @@ public class AccountHelper {
account.setNumber(number);
account.setAci(aci);
account.setPni(pni);
if (account.isPrimaryDevice() && account.getPniIdentityKeyPair() == null && account.getPni() != null) {
account.setPniIdentityKeyPair(KeyUtils.generateIdentityKeyPair());
}
account.getRecipientTrustedResolver().resolveSelfRecipientTrusted(account.getSelfRecipientAddress());
// TODO check and update remote storage
context.getUnidentifiedAccessHelper().rotateSenderCertificates();

View file

@ -402,7 +402,7 @@ public class SignalAccount implements Closeable {
// Old config file, creating new profile key
setProfileKey(KeyUtils.createProfileKey());
}
if (isPrimaryDevice() && getPniIdentityKeyPair() == null) {
if (isPrimaryDevice() && getPniIdentityKeyPair() == null && getPni() != null) {
setPniIdentityKeyPair(KeyUtils.generateIdentityKeyPair());
}
}