Add parameter to configure phone number privacy
This commit is contained in:
		
							parent
							
								
									25258db55d
								
							
						
					
					
						commit
						6cd57312a1
					
				| @ -316,6 +316,10 @@ pub enum CliCommands { | ||||
|         device_name: Option<String>, | ||||
|         #[arg(long = "unrestricted-unidentified-sender")] | ||||
|         unrestricted_unidentified_sender: Option<bool>, | ||||
|         #[arg(long = "discoverable-by-number")] | ||||
|         discoverable_by_number: Option<bool>, | ||||
|         #[arg(long = "number-sharing")] | ||||
|         number_sharing: Option<bool>, | ||||
|     }, | ||||
|     UpdateConfiguration { | ||||
|         #[arg(long = "read-receipts")] | ||||
|  | ||||
| @ -301,6 +301,8 @@ pub trait Rpc { | ||||
|         account: Option<String>, | ||||
|         deviceName: Option<String>, | ||||
|         unrestrictedUnidentifiedSender: Option<bool>, | ||||
|         discoverableByNumber: Option<bool>, | ||||
|         numberSharing: Option<bool>, | ||||
|     ) -> Result<Value, ErrorObjectOwned>; | ||||
| 
 | ||||
|     #[method(name = "updateConfiguration", param_kind = map)] | ||||
|  | ||||
| @ -275,9 +275,17 @@ async fn handle_command( | ||||
|         CliCommands::UpdateAccount { | ||||
|             device_name, | ||||
|             unrestricted_unidentified_sender, | ||||
|             discoverable_by_number, | ||||
|             number_sharing, | ||||
|         } => { | ||||
|             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 | ||||
|         } | ||||
|         CliCommands::UpdateConfiguration { | ||||
|  | ||||
| @ -90,7 +90,12 @@ public interface Manager extends Closeable { | ||||
|      */ | ||||
|     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(); | ||||
| 
 | ||||
|  | ||||
| @ -43,6 +43,7 @@ import org.asamk.signal.manager.api.NotAGroupMemberException; | ||||
| import org.asamk.signal.manager.api.NotPrimaryDeviceException; | ||||
| import org.asamk.signal.manager.api.Pair; | ||||
| 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.Profile; | ||||
| import org.asamk.signal.manager.api.RateLimitException; | ||||
| @ -277,13 +278,27 @@ public class ManagerImpl implements Manager { | ||||
|     } | ||||
| 
 | ||||
|     @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) { | ||||
|             context.getAccountHelper().setDeviceName(deviceName); | ||||
|         } | ||||
|         if (unrestrictedUnidentifiedSender != null) { | ||||
|             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().checkWhoAmiI(); | ||||
|     } | ||||
|  | ||||
| @ -118,7 +118,6 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal | ||||
|                 .setLinkPreviewsEnabled(linkPreviews) | ||||
|                 .setUnlistedPhoneNumber(unlisted) | ||||
|                 .setPhoneNumberSharingMode(phoneNumberSharingMode) | ||||
|                 .setUnlistedPhoneNumber(unlisted) | ||||
|                 .setPinnedConversations(pinnedConversations) | ||||
|                 .setPreferContactAvatars(preferContactAvatars) | ||||
|                 .setPayments(payments.isEnabled(), payments.getEntropy().orElse(null)) | ||||
|  | ||||
| @ -62,7 +62,7 @@ public final class StorageSyncModels { | ||||
|                 .setSealedSenderIndicatorsEnabled(Optional.ofNullable(configStore.getUnidentifiedDeliveryIndicators()) | ||||
|                         .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()) | ||||
|                         .orElse(PhoneNumberSharingMode.EVERYBODY))) | ||||
|                 .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}:: | ||||
| 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 | ||||
| 
 | ||||
| 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") | ||||
|                 .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); | ||||
|         } | ||||
|  | ||||
| @ -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(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -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) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 AsamK
						AsamK