final var storageId = newContactStorageIds.get(recipientId);
if (storageId.getType() == ManifestRecord.Identifier.Type.ACCOUNT.getValue()) {
final var recipient = account.getRecipientStore().getRecipient(connection, recipientId);
- final var accountRecord = StorageSyncModels.localToRemoteRecord(account.getConfigurationStore(),
+ final var accountRecord = StorageSyncModels.localToRemoteRecord(connection,
+ account.getConfigurationStore(),
recipient,
account.getUsernameLink());
newStorageRecords.add(new SignalStorageRecord(storageId,
final var selfRecipient = account.getRecipientStore()
.getRecipient(connection, account.getSelfRecipientId());
- final var record = StorageSyncModels.localToRemoteRecord(account.getConfigurationStore(),
+ final var record = StorageSyncModels.localToRemoteRecord(connection,
+ account.getConfigurationStore(),
selfRecipient,
account.getUsernameLink());
yield new SignalStorageRecord(storageId, new StorageRecord.Builder().account(record).build());
return keyValueStore.getEntry(readReceipts);
}
+ public Boolean getReadReceipts(final Connection connection) throws SQLException {
+ return keyValueStore.getEntry(connection, readReceipts);
+ }
+
public void setReadReceipts(final boolean value) {
if (keyValueStore.storeEntry(readReceipts, value)) {
recipientStore.rotateSelfStorageId();
return keyValueStore.getEntry(unidentifiedDeliveryIndicators);
}
+ public Boolean getUnidentifiedDeliveryIndicators(final Connection connection) throws SQLException {
+ return keyValueStore.getEntry(connection, unidentifiedDeliveryIndicators);
+ }
+
public void setUnidentifiedDeliveryIndicators(final boolean value) {
if (keyValueStore.storeEntry(unidentifiedDeliveryIndicators, value)) {
recipientStore.rotateSelfStorageId();
return keyValueStore.getEntry(typingIndicators);
}
+ public Boolean getTypingIndicators(final Connection connection) throws SQLException {
+ return keyValueStore.getEntry(connection, typingIndicators);
+ }
+
public void setTypingIndicators(final boolean value) {
if (keyValueStore.storeEntry(typingIndicators, value)) {
recipientStore.rotateSelfStorageId();
return keyValueStore.getEntry(linkPreviews);
}
+ public Boolean getLinkPreviews(final Connection connection) throws SQLException {
+ return keyValueStore.getEntry(connection, linkPreviews);
+ }
+
public void setLinkPreviews(final boolean value) {
if (keyValueStore.storeEntry(linkPreviews, value)) {
recipientStore.rotateSelfStorageId();
return keyValueStore.getEntry(phoneNumberUnlisted);
}
+ public Boolean getPhoneNumberUnlisted(final Connection connection) throws SQLException {
+ return keyValueStore.getEntry(connection, phoneNumberUnlisted);
+ }
+
public void setPhoneNumberUnlisted(final boolean value) {
if (keyValueStore.storeEntry(phoneNumberUnlisted, value)) {
recipientStore.rotateSelfStorageId();
return keyValueStore.getEntry(phoneNumberSharingMode);
}
+ public PhoneNumberSharingMode getPhoneNumberSharingMode(final Connection connection) throws SQLException {
+ return keyValueStore.getEntry(connection, phoneNumberSharingMode);
+ }
+
public void setPhoneNumberSharingMode(final PhoneNumberSharingMode value) {
if (keyValueStore.storeEntry(phoneNumberSharingMode, value)) {
recipientStore.rotateSelfStorageId();
return keyValueStore.getEntry(usernameLinkColor);
}
+ public String getUsernameLinkColor(final Connection connection) throws SQLException {
+ return keyValueStore.getEntry(connection, usernameLinkColor);
+ }
+
public void setUsernameLinkColor(final String color) {
if (keyValueStore.storeEntry(usernameLinkColor, color)) {
recipientStore.rotateSelfStorageId();
}
}
- private <T> T getEntry(final Connection connection, final KeyValueEntry<T> key) throws SQLException {
+ public <T> T getEntry(final Connection connection, final KeyValueEntry<T> key) throws SQLException {
final var sql = (
"""
SELECT key, value
final var recipient = account.getRecipientStore().getRecipient(connection, selfRecipientId);
final var storageId = account.getRecipientStore().getSelfStorageId(connection);
this.localAccountRecord = new SignalAccountRecord(storageId,
- StorageSyncModels.localToRemoteRecord(account.getConfigurationStore(),
+ StorageSyncModels.localToRemoteRecord(connection,
+ account.getConfigurationStore(),
recipient,
account.getUsernameLink()));
}
import org.whispersystems.signalservice.internal.storage.protos.GroupV1Record;
import org.whispersystems.signalservice.internal.storage.protos.GroupV2Record;
+import java.sql.Connection;
+import java.sql.SQLException;
import java.util.Optional;
import okio.ByteString;
}
public static AccountRecord localToRemoteRecord(
+ final Connection connection,
ConfigurationStore configStore,
Recipient self,
UsernameLinkComponents usernameLinkComponents
- ) {
+ ) throws SQLException {
final var builder = SignalAccountRecord.Companion.newBuilder(self.getStorageRecord());
if (self.getProfileKey() != null) {
builder.profileKey(ByteString.of(self.getProfileKey().serialize()));
.familyName(emptyIfNull(self.getProfile().getFamilyName()))
.avatarUrlPath(emptyIfNull(self.getProfile().getAvatarUrlPath()));
}
- builder.typingIndicators(Optional.ofNullable(configStore.getTypingIndicators()).orElse(true))
- .readReceipts(Optional.ofNullable(configStore.getReadReceipts()).orElse(true))
- .sealedSenderIndicators(Optional.ofNullable(configStore.getUnidentifiedDeliveryIndicators())
+ builder.typingIndicators(Optional.ofNullable(configStore.getTypingIndicators(connection)).orElse(true))
+ .readReceipts(Optional.ofNullable(configStore.getReadReceipts(connection)).orElse(true))
+ .sealedSenderIndicators(Optional.ofNullable(configStore.getUnidentifiedDeliveryIndicators(connection))
.orElse(true))
- .linkPreviews(Optional.ofNullable(configStore.getLinkPreviews()).orElse(true))
- .unlistedPhoneNumber(Optional.ofNullable(configStore.getPhoneNumberUnlisted()).orElse(false))
- .phoneNumberSharingMode(Optional.ofNullable(configStore.getPhoneNumberSharingMode())
+ .linkPreviews(Optional.ofNullable(configStore.getLinkPreviews(connection)).orElse(true))
+ .unlistedPhoneNumber(Optional.ofNullable(configStore.getPhoneNumberUnlisted(connection)).orElse(false))
+ .phoneNumberSharingMode(Optional.ofNullable(configStore.getPhoneNumberSharingMode(connection))
.map(StorageSyncModels::localToRemote)
.orElse(AccountRecord.PhoneNumberSharingMode.UNKNOWN))
.e164(self.getAddress().number().orElse(""))
.username(self.getAddress().username().orElse(""));
if (usernameLinkComponents != null) {
- final var linkColor = configStore.getUsernameLinkColor();
+ final var linkColor = configStore.getUsernameLinkColor(connection);
builder.usernameLink(new UsernameLink.Builder().entropy(ByteString.of(usernameLinkComponents.getEntropy()))
.serverId(UuidUtil.toByteString(usernameLinkComponents.getServerId()))
.color(linkColor == null ? UsernameLink.Color.UNKNOWN : UsernameLink.Color.valueOf(linkColor))