mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Add parameter to configure phone number privacy
This commit is contained in:
parent
25258db55d
commit
6cd57312a1
11 changed files with 60 additions and 8 deletions
|
@ -316,6 +316,10 @@ pub enum CliCommands {
|
||||||
device_name: Option<String>,
|
device_name: Option<String>,
|
||||||
#[arg(long = "unrestricted-unidentified-sender")]
|
#[arg(long = "unrestricted-unidentified-sender")]
|
||||||
unrestricted_unidentified_sender: Option<bool>,
|
unrestricted_unidentified_sender: Option<bool>,
|
||||||
|
#[arg(long = "discoverable-by-number")]
|
||||||
|
discoverable_by_number: Option<bool>,
|
||||||
|
#[arg(long = "number-sharing")]
|
||||||
|
number_sharing: Option<bool>,
|
||||||
},
|
},
|
||||||
UpdateConfiguration {
|
UpdateConfiguration {
|
||||||
#[arg(long = "read-receipts")]
|
#[arg(long = "read-receipts")]
|
||||||
|
|
|
@ -301,6 +301,8 @@ pub trait Rpc {
|
||||||
account: Option<String>,
|
account: Option<String>,
|
||||||
deviceName: Option<String>,
|
deviceName: Option<String>,
|
||||||
unrestrictedUnidentifiedSender: Option<bool>,
|
unrestrictedUnidentifiedSender: Option<bool>,
|
||||||
|
discoverableByNumber: Option<bool>,
|
||||||
|
numberSharing: Option<bool>,
|
||||||
) -> Result<Value, ErrorObjectOwned>;
|
) -> Result<Value, ErrorObjectOwned>;
|
||||||
|
|
||||||
#[method(name = "updateConfiguration", param_kind = map)]
|
#[method(name = "updateConfiguration", param_kind = map)]
|
||||||
|
|
|
@ -275,9 +275,17 @@ async fn handle_command(
|
||||||
CliCommands::UpdateAccount {
|
CliCommands::UpdateAccount {
|
||||||
device_name,
|
device_name,
|
||||||
unrestricted_unidentified_sender,
|
unrestricted_unidentified_sender,
|
||||||
|
discoverable_by_number,
|
||||||
|
number_sharing,
|
||||||
} => {
|
} => {
|
||||||
client
|
client
|
||||||
.update_account(cli.account, device_name, unrestricted_unidentified_sender)
|
.update_account(
|
||||||
|
cli.account,
|
||||||
|
device_name,
|
||||||
|
unrestricted_unidentified_sender,
|
||||||
|
discoverable_by_number,
|
||||||
|
number_sharing,
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
CliCommands::UpdateConfiguration {
|
CliCommands::UpdateConfiguration {
|
||||||
|
|
|
@ -90,7 +90,12 @@ public interface Manager extends Closeable {
|
||||||
*/
|
*/
|
||||||
Map<String, UserStatus> getUserStatus(Set<String> numbers) throws IOException, RateLimitException;
|
Map<String, UserStatus> getUserStatus(Set<String> numbers) throws IOException, RateLimitException;
|
||||||
|
|
||||||
void updateAccountAttributes(String deviceName, Boolean unrestrictedUnidentifiedSender) throws IOException;
|
void updateAccountAttributes(
|
||||||
|
String deviceName,
|
||||||
|
Boolean unrestrictedUnidentifiedSender,
|
||||||
|
final Boolean discoverableByNumber,
|
||||||
|
final Boolean numberSharing
|
||||||
|
) throws IOException;
|
||||||
|
|
||||||
Configuration getConfiguration();
|
Configuration getConfiguration();
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.asamk.signal.manager.api.NotAGroupMemberException;
|
||||||
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
|
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
|
||||||
import org.asamk.signal.manager.api.Pair;
|
import org.asamk.signal.manager.api.Pair;
|
||||||
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
||||||
|
import org.asamk.signal.manager.api.PhoneNumberSharingMode;
|
||||||
import org.asamk.signal.manager.api.PinLockedException;
|
import org.asamk.signal.manager.api.PinLockedException;
|
||||||
import org.asamk.signal.manager.api.Profile;
|
import org.asamk.signal.manager.api.Profile;
|
||||||
import org.asamk.signal.manager.api.RateLimitException;
|
import org.asamk.signal.manager.api.RateLimitException;
|
||||||
|
@ -277,13 +278,27 @@ public class ManagerImpl implements Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAccountAttributes(String deviceName, Boolean unrestrictedUnidentifiedSender) throws IOException {
|
public void updateAccountAttributes(
|
||||||
|
String deviceName,
|
||||||
|
Boolean unrestrictedUnidentifiedSender,
|
||||||
|
final Boolean discoverableByNumber,
|
||||||
|
final Boolean numberSharing
|
||||||
|
) throws IOException {
|
||||||
if (deviceName != null) {
|
if (deviceName != null) {
|
||||||
context.getAccountHelper().setDeviceName(deviceName);
|
context.getAccountHelper().setDeviceName(deviceName);
|
||||||
}
|
}
|
||||||
if (unrestrictedUnidentifiedSender != null) {
|
if (unrestrictedUnidentifiedSender != null) {
|
||||||
account.setUnrestrictedUnidentifiedAccess(unrestrictedUnidentifiedSender);
|
account.setUnrestrictedUnidentifiedAccess(unrestrictedUnidentifiedSender);
|
||||||
}
|
}
|
||||||
|
if (discoverableByNumber != null) {
|
||||||
|
account.getConfigurationStore().setPhoneNumberUnlisted(!discoverableByNumber);
|
||||||
|
}
|
||||||
|
if (numberSharing != null) {
|
||||||
|
account.getConfigurationStore()
|
||||||
|
.setPhoneNumberSharingMode(numberSharing
|
||||||
|
? PhoneNumberSharingMode.EVERYBODY
|
||||||
|
: PhoneNumberSharingMode.NOBODY);
|
||||||
|
}
|
||||||
context.getAccountHelper().updateAccountAttributes();
|
context.getAccountHelper().updateAccountAttributes();
|
||||||
context.getAccountHelper().checkWhoAmiI();
|
context.getAccountHelper().checkWhoAmiI();
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,6 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
||||||
.setLinkPreviewsEnabled(linkPreviews)
|
.setLinkPreviewsEnabled(linkPreviews)
|
||||||
.setUnlistedPhoneNumber(unlisted)
|
.setUnlistedPhoneNumber(unlisted)
|
||||||
.setPhoneNumberSharingMode(phoneNumberSharingMode)
|
.setPhoneNumberSharingMode(phoneNumberSharingMode)
|
||||||
.setUnlistedPhoneNumber(unlisted)
|
|
||||||
.setPinnedConversations(pinnedConversations)
|
.setPinnedConversations(pinnedConversations)
|
||||||
.setPreferContactAvatars(preferContactAvatars)
|
.setPreferContactAvatars(preferContactAvatars)
|
||||||
.setPayments(payments.isEnabled(), payments.getEntropy().orElse(null))
|
.setPayments(payments.isEnabled(), payments.getEntropy().orElse(null))
|
||||||
|
|
|
@ -62,7 +62,7 @@ public final class StorageSyncModels {
|
||||||
.setSealedSenderIndicatorsEnabled(Optional.ofNullable(configStore.getUnidentifiedDeliveryIndicators())
|
.setSealedSenderIndicatorsEnabled(Optional.ofNullable(configStore.getUnidentifiedDeliveryIndicators())
|
||||||
.orElse(true))
|
.orElse(true))
|
||||||
.setLinkPreviewsEnabled(Optional.ofNullable(configStore.getLinkPreviews()).orElse(true))
|
.setLinkPreviewsEnabled(Optional.ofNullable(configStore.getLinkPreviews()).orElse(true))
|
||||||
.setUnlistedPhoneNumber(Optional.ofNullable(configStore.getPhoneNumberUnlisted()).orElse(true))
|
.setUnlistedPhoneNumber(Optional.ofNullable(configStore.getPhoneNumberUnlisted()).orElse(false))
|
||||||
.setPhoneNumberSharingMode(localToRemote(Optional.ofNullable(configStore.getPhoneNumberSharingMode())
|
.setPhoneNumberSharingMode(localToRemote(Optional.ofNullable(configStore.getPhoneNumberSharingMode())
|
||||||
.orElse(PhoneNumberSharingMode.EVERYBODY)))
|
.orElse(PhoneNumberSharingMode.EVERYBODY)))
|
||||||
.setE164(self.getAddress().number().orElse(""))
|
.setE164(self.getAddress().number().orElse(""))
|
||||||
|
|
|
@ -154,6 +154,12 @@ Set a new device name for the primary or linked device
|
||||||
*--unrestricted-unidentified-sender* {true,false}::
|
*--unrestricted-unidentified-sender* {true,false}::
|
||||||
Enable if anyone should be able to send you unidentified sender messages.
|
Enable if anyone should be able to send you unidentified sender messages.
|
||||||
|
|
||||||
|
*--discoverable-by-number* {true,false}::
|
||||||
|
Enable/disable if the account should be discoverable by phone number
|
||||||
|
|
||||||
|
*--number-sharing* {true,false}::
|
||||||
|
Indicates if Signal should share its phone number when sending a message.
|
||||||
|
|
||||||
=== startChangeNumber
|
=== startChangeNumber
|
||||||
|
|
||||||
Change an account to a new phone number with SMS or voice verification.
|
Change an account to a new phone number with SMS or voice verification.
|
||||||
|
|
|
@ -31,6 +31,12 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
|
||||||
subparser.addArgument("--unrestricted-unidentified-sender")
|
subparser.addArgument("--unrestricted-unidentified-sender")
|
||||||
.type(Boolean.class)
|
.type(Boolean.class)
|
||||||
.help("Enable if anyone should be able to send you unidentified sender messages.");
|
.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();
|
var mut = subparser.addMutuallyExclusiveGroup();
|
||||||
mut.addArgument("-u", "--username").help("Specify a username that can then be used to contact this account.");
|
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 {
|
) throws CommandException {
|
||||||
final var deviceName = ns.getString("device-name");
|
final var deviceName = ns.getString("device-name");
|
||||||
final var unrestrictedUnidentifiedSender = ns.getBoolean("unrestricted-unidentified-sender");
|
final var unrestrictedUnidentifiedSender = ns.getBoolean("unrestricted-unidentified-sender");
|
||||||
|
final var discoverableByNumber = ns.getBoolean("discoverable-by-number");
|
||||||
|
final var numberSharing = ns.getBoolean("number-sharing");
|
||||||
try {
|
try {
|
||||||
m.updateAccountAttributes(deviceName, unrestrictedUnidentifiedSender);
|
m.updateAccountAttributes(deviceName, unrestrictedUnidentifiedSender, discoverableByNumber, numberSharing);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IOErrorException("UpdateAccount error: " + e.getMessage(), e);
|
throw new IOErrorException("UpdateAccount error: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,11 +124,16 @@ public class DbusManagerImpl implements Manager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAccountAttributes(
|
public void updateAccountAttributes(
|
||||||
final String deviceName, final Boolean unrestrictedUnidentifiedSender
|
final String deviceName,
|
||||||
|
final Boolean unrestrictedUnidentifiedSender,
|
||||||
|
final Boolean discoverableByNumber,
|
||||||
|
final Boolean numberSharing
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
if (deviceName != null) {
|
if (deviceName != null) {
|
||||||
final var devicePath = signal.getThisDevice();
|
final var devicePath = signal.getThisDevice();
|
||||||
getRemoteObject(devicePath, Signal.Device.class).Set("org.asamk.Signal.Device", "Name", deviceName);
|
getRemoteObject(devicePath, Signal.Device.class).Set("org.asamk.Signal.Device", "Name", deviceName);
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1187,7 +1187,7 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
||||||
throw new Error.Failure("Only the name of this device can be changed");
|
throw new Error.Failure("Only the name of this device can be changed");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
m.updateAccountAttributes(name, null);
|
m.updateAccountAttributes(name, null, null, null);
|
||||||
// update device list
|
// update device list
|
||||||
updateDevices();
|
updateDevices();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue