if (account.getUuid() == null) {
account.setUuid(dependencies.getAccountManager().getOwnUuid());
}
- updateAccountAttributes();
+ updateAccountAttributes(null);
}
/**
}));
}
- public void updateAccountAttributes() throws IOException {
+ public void updateAccountAttributes(String deviceName) throws IOException {
+ final String encryptedDeviceName;
+ if (deviceName == null) {
+ encryptedDeviceName = account.getEncryptedDeviceName();
+ } else {
+ final var privateKey = account.getIdentityKeyPair().getPrivateKey();
+ encryptedDeviceName = DeviceNameUtil.encryptDeviceName(deviceName, privateKey);
+ account.setEncryptedDeviceName(encryptedDeviceName);
+ }
dependencies.getAccountManager()
- .setAccountAttributes(account.getEncryptedDeviceName(),
+ .setAccountAttributes(encryptedDeviceName,
null,
account.getLocalRegistrationId(),
true,
- // set legacy pin only if no KBS master key is set
- account.getPinMasterKey() == null ? account.getRegistrationLockPin() : null,
+ null,
account.getPinMasterKey() == null ? null : account.getPinMasterKey().deriveRegistrationLock(),
account.getSelfUnidentifiedAccessKey(),
account.isUnrestrictedUnidentifiedAccess(),
Update the account attributes on the signal server.
Can fix problems with receiving messages.
+*-n* NAME, *--device-name* NAME::
+Set a new device name for the main or linked device
+
=== setPin
Set a registration lock pin, to prevent others from registering this number.
@Override
public void attachToSubparser(final Subparser subparser) {
subparser.help("Update the account attributes on the signal server.");
+ subparser.addArgument("-n", "--device-name").help("Specify a name to describe this device.");
}
@Override
public void handleCommand(
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
+ var deviceName = ns.getString("device-name");
try {
- m.updateAccountAttributes();
+ m.updateAccountAttributes(deviceName);
} catch (IOException e) {
throw new IOErrorException("UpdateAccount error: " + e.getMessage());
}