mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Update self identifiers after whoAmI request
This commit is contained in:
parent
7a06d3959e
commit
8985cc2656
3 changed files with 32 additions and 3 deletions
|
@ -52,9 +52,7 @@ public class AccountHelper {
|
||||||
try {
|
try {
|
||||||
context.getPreKeyHelper().refreshPreKeysIfNecessary();
|
context.getPreKeyHelper().refreshPreKeysIfNecessary();
|
||||||
if (account.getAci() == null) {
|
if (account.getAci() == null) {
|
||||||
final var aci = ACI.parseOrNull(dependencies.getAccountManager().getWhoAmI().getAci());
|
checkWhoAmiI();
|
||||||
account.setAci(aci);
|
|
||||||
context.getAccountFileUpdater().updateAccountIdentifiers(account.getNumber(), aci);
|
|
||||||
}
|
}
|
||||||
updateAccountAttributes();
|
updateAccountAttributes();
|
||||||
} catch (AuthorizationFailedException e) {
|
} catch (AuthorizationFailedException e) {
|
||||||
|
@ -63,6 +61,27 @@ public class AccountHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkWhoAmiI() throws IOException {
|
||||||
|
final var whoAmI = dependencies.getAccountManager().getWhoAmI();
|
||||||
|
final var number = whoAmI.getNumber();
|
||||||
|
final var aci = ACI.parseOrNull(whoAmI.getAci());
|
||||||
|
if (number.equals(account.getNumber()) && aci.equals(account.getAci())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSelfIdentifiers(number, aci);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSelfIdentifiers(final String number, final ACI aci) {
|
||||||
|
account.setNumber(number);
|
||||||
|
account.setAci(aci);
|
||||||
|
account.getRecipientStore().resolveRecipientTrusted(account.getSelfRecipientAddress());
|
||||||
|
context.getAccountFileUpdater().updateAccountIdentifiers(account.getNumber(), account.getAci());
|
||||||
|
// TODO check and update remote storage
|
||||||
|
context.getUnidentifiedAccessHelper().rotateSenderCertificates();
|
||||||
|
dependencies.getSignalWebSocket().forceNewWebSockets();
|
||||||
|
}
|
||||||
|
|
||||||
public void setDeviceName(String deviceName) {
|
public void setDeviceName(String deviceName) {
|
||||||
final var privateKey = account.getIdentityKeyPair().getPrivateKey();
|
final var privateKey = account.getIdentityKeyPair().getPrivateKey();
|
||||||
final var encryptedDeviceName = DeviceNameUtil.encryptDeviceName(deviceName, privateKey);
|
final var encryptedDeviceName = DeviceNameUtil.encryptDeviceName(deviceName, privateKey);
|
||||||
|
|
|
@ -37,6 +37,11 @@ public class UnidentifiedAccessHelper {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rotateSenderCertificates() {
|
||||||
|
privacySenderCertificate = null;
|
||||||
|
senderCertificate = null;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Optional<UnidentifiedAccessPair>> getAccessFor(List<RecipientId> recipients) {
|
public List<Optional<UnidentifiedAccessPair>> getAccessFor(List<RecipientId> recipients) {
|
||||||
return recipients.stream().map(this::getAccessFor).toList();
|
return recipients.stream().map(this::getAccessFor).toList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -930,6 +930,11 @@ public class SignalAccount implements Closeable {
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNumber(final String number) {
|
||||||
|
this.number = number;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
public ACI getAci() {
|
public ACI getAci() {
|
||||||
return aci;
|
return aci;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue