Add parameter to configure phone number privacy

This commit is contained in:
AsamK 2024-02-18 19:24:23 +01:00
parent 25258db55d
commit 6cd57312a1
11 changed files with 60 additions and 8 deletions

View file

@ -31,6 +31,12 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
subparser.addArgument("--unrestricted-unidentified-sender")
.type(Boolean.class)
.help("Enable if anyone should be able to send you unidentified sender messages.");
subparser.addArgument("--discoverable-by-number")
.type(Boolean.class)
.help("Enable/disable if the account should be discoverable by phone number");
subparser.addArgument("--number-sharing")
.type(Boolean.class)
.help("Indicates if Signal should share its phone number when sending a message.");
var mut = subparser.addMutuallyExclusiveGroup();
mut.addArgument("-u", "--username").help("Specify a username that can then be used to contact this account.");
@ -45,8 +51,10 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
) throws CommandException {
final var deviceName = ns.getString("device-name");
final var unrestrictedUnidentifiedSender = ns.getBoolean("unrestricted-unidentified-sender");
final var discoverableByNumber = ns.getBoolean("discoverable-by-number");
final var numberSharing = ns.getBoolean("number-sharing");
try {
m.updateAccountAttributes(deviceName, unrestrictedUnidentifiedSender);
m.updateAccountAttributes(deviceName, unrestrictedUnidentifiedSender, discoverableByNumber, numberSharing);
} catch (IOException e) {
throw new IOErrorException("UpdateAccount error: " + e.getMessage(), e);
}

View file

@ -124,11 +124,16 @@ public class DbusManagerImpl implements Manager {
@Override
public void updateAccountAttributes(
final String deviceName, final Boolean unrestrictedUnidentifiedSender
final String deviceName,
final Boolean unrestrictedUnidentifiedSender,
final Boolean discoverableByNumber,
final Boolean numberSharing
) throws IOException {
if (deviceName != null) {
final var devicePath = signal.getThisDevice();
getRemoteObject(devicePath, Signal.Device.class).Set("org.asamk.Signal.Device", "Name", deviceName);
} else {
throw new UnsupportedOperationException();
}
}

View file

@ -1187,7 +1187,7 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
throw new Error.Failure("Only the name of this device can be changed");
}
try {
m.updateAccountAttributes(name, null);
m.updateAccountAttributes(name, null, null, null);
// update device list
updateDevices();
} catch (IOException e) {