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

@ -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();

View file

@ -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();
}

View file

@ -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))

View file

@ -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(""))