Add --unrestricted-unidentified-sender to updateAccount command

This commit is contained in:
AsamK 2024-01-13 16:00:55 +01:00
parent 3290a5bf4d
commit 30e8e36635
9 changed files with 38 additions and 10 deletions

View file

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

View file

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

View file

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

View file

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