mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Add --unrestricted-unidentified-sender to updateAccount command
This commit is contained in:
parent
3290a5bf4d
commit
30e8e36635
9 changed files with 38 additions and 10 deletions
|
@ -8,6 +8,7 @@
|
|||
- New --hidden parameter for removeContact command
|
||||
- New --notify-self parameter for send command, for sending a non-sync message when self is part of the recipients or groups.
|
||||
With this parameter sending to the self number (+XXXX) now behaves the same as the --note-to-self parameter.
|
||||
- New --unrestricted-unidentified-sender parameter for updateAccount command
|
||||
|
||||
### Improved
|
||||
- Better shutdown handling after Ctrl+C and SIGTERM
|
||||
|
|
|
@ -89,7 +89,7 @@ public interface Manager extends Closeable {
|
|||
*/
|
||||
Map<String, UserStatus> getUserStatus(Set<String> numbers) throws IOException, RateLimitException;
|
||||
|
||||
void updateAccountAttributes(String deviceName) throws IOException;
|
||||
void updateAccountAttributes(String deviceName, Boolean unrestrictedUnidentifiedSender) throws IOException;
|
||||
|
||||
Configuration getConfiguration();
|
||||
|
||||
|
|
|
@ -328,6 +328,13 @@ public final class ProfileHelper {
|
|||
|
||||
final var profile = account.getProfileStore().getProfile(recipientId);
|
||||
|
||||
if (recipientId.equals(account.getSelfRecipientId())) {
|
||||
final var isUnrestricted = encryptedProfile.isUnrestrictedUnidentifiedAccess();
|
||||
if (account.isUnrestrictedUnidentifiedAccess() != isUnrestricted) {
|
||||
account.setUnrestrictedUnidentifiedAccess(isUnrestricted);
|
||||
}
|
||||
}
|
||||
|
||||
Profile newProfile = null;
|
||||
if (profileKey.isPresent()) {
|
||||
logger.trace("Decrypting profile");
|
||||
|
|
|
@ -277,10 +277,13 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateAccountAttributes(String deviceName) throws IOException {
|
||||
public void updateAccountAttributes(String deviceName, Boolean unrestrictedUnidentifiedSender) throws IOException {
|
||||
if (deviceName != null) {
|
||||
context.getAccountHelper().setDeviceName(deviceName);
|
||||
}
|
||||
if (unrestrictedUnidentifiedSender != null) {
|
||||
account.setUnrestrictedUnidentifiedAccess(unrestrictedUnidentifiedSender);
|
||||
}
|
||||
context.getAccountHelper().updateAccountAttributes();
|
||||
context.getAccountHelper().checkWhoAmiI();
|
||||
}
|
||||
|
|
|
@ -154,6 +154,10 @@ public class SignalAccount implements Closeable {
|
|||
private final KeyValueEntry<Long> storageManifestVersion = new KeyValueEntry<>("storage-manifest-version",
|
||||
long.class,
|
||||
-1L);
|
||||
private final KeyValueEntry<Boolean> unrestrictedUnidentifiedAccess = new KeyValueEntry<>(
|
||||
"unrestricted-unidentified-access",
|
||||
Boolean.class,
|
||||
false);
|
||||
private boolean isMultiDevice = false;
|
||||
private boolean registered = false;
|
||||
|
||||
|
@ -1594,8 +1598,11 @@ public class SignalAccount implements Closeable {
|
|||
}
|
||||
|
||||
public boolean isUnrestrictedUnidentifiedAccess() {
|
||||
final var profile = getProfileStore().getProfile(getSelfRecipientId());
|
||||
return profile != null && profile.getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.UNRESTRICTED;
|
||||
return Boolean.TRUE.equals(getKeyValueStore().getEntry(unrestrictedUnidentifiedAccess));
|
||||
}
|
||||
|
||||
public void setUnrestrictedUnidentifiedAccess(boolean value) {
|
||||
getKeyValueStore().storeEntry(unrestrictedUnidentifiedAccess, value);
|
||||
}
|
||||
|
||||
public boolean isDiscoverableByPhoneNumber() {
|
||||
|
|
|
@ -147,6 +147,9 @@ Can fix problems with receiving messages.
|
|||
*-n* NAME, *--device-name* NAME::
|
||||
Set a new device name for the primary or linked device
|
||||
|
||||
*--unrestricted-unidentified-sender* {true,false}::
|
||||
Enable if anyone should be able to send you unidentified sender messages.
|
||||
|
||||
=== startChangeNumber
|
||||
|
||||
Change an account to a new phone number with SMS or voice verification.
|
||||
|
|
|
@ -28,6 +28,10 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
|
|||
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.");
|
||||
subparser.addArgument("--unrestricted-unidentified-sender")
|
||||
.type(Boolean.class)
|
||||
.help("Enable if anyone should be able to send you unidentified sender messages.");
|
||||
|
||||
var mut = subparser.addMutuallyExclusiveGroup();
|
||||
mut.addArgument("-u", "--username").help("Specify a username that can then be used to contact this account.");
|
||||
mut.addArgument("--delete-username")
|
||||
|
@ -39,14 +43,15 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
|
|||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
var deviceName = ns.getString("device-name");
|
||||
final var deviceName = ns.getString("device-name");
|
||||
final var unrestrictedUnidentifiedSender = ns.getBoolean("unrestricted-unidentified-sender");
|
||||
try {
|
||||
m.updateAccountAttributes(deviceName);
|
||||
m.updateAccountAttributes(deviceName, unrestrictedUnidentifiedSender);
|
||||
} catch (IOException e) {
|
||||
throw new IOErrorException("UpdateAccount error: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
var username = ns.getString("username");
|
||||
final var username = ns.getString("username");
|
||||
if (username != null) {
|
||||
try {
|
||||
m.setUsername(username);
|
||||
|
@ -66,7 +71,7 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
|
|||
}
|
||||
}
|
||||
|
||||
var deleteUsername = Boolean.TRUE.equals(ns.getBoolean("delete-username"));
|
||||
final var deleteUsername = Boolean.TRUE.equals(ns.getBoolean("delete-username"));
|
||||
if (deleteUsername) {
|
||||
try {
|
||||
m.deleteUsername();
|
||||
|
|
|
@ -121,7 +121,9 @@ public class DbusManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateAccountAttributes(final String deviceName) throws IOException {
|
||||
public void updateAccountAttributes(
|
||||
final String deviceName, final Boolean unrestrictedUnidentifiedSender
|
||||
) throws IOException {
|
||||
if (deviceName != null) {
|
||||
final var devicePath = signal.getThisDevice();
|
||||
getRemoteObject(devicePath, Signal.Device.class).Set("org.asamk.Signal.Device", "Name", deviceName);
|
||||
|
|
|
@ -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);
|
||||
m.updateAccountAttributes(name, null);
|
||||
// update device list
|
||||
updateDevices();
|
||||
} catch (IOException e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue