Add missing parts for new nick name and note columns

This commit is contained in:
AsamK 2024-04-17 20:50:03 +02:00
parent 7e0d4c9b89
commit 8aeaf927e6
3 changed files with 24 additions and 11 deletions

View file

@ -41,7 +41,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
private static final Logger logger = LoggerFactory.getLogger(RecipientStore.class);
private static final String TABLE_RECIPIENT = "recipient";
private static final String SQL_IS_CONTACT = "r.given_name IS NOT NULL OR r.family_name IS NOT NULL OR r.nick_name IS NOT NULL OR r.expiration_time > 0 OR r.profile_sharing = TRUE OR r.color IS NOT NULL OR r.blocked = TRUE OR r.archived = TRUE";
private static final String SQL_IS_CONTACT = "r.given_name IS NOT NULL OR r.family_name IS NOT NULL OR r.nick_name IS NOT NULL OR r.nick_name_given_name IS NOT NULL OR r.nick_name_family_name IS NOT NULL OR r.note IS NOT NULL OR r.expiration_time > 0 OR r.profile_sharing = TRUE OR r.color IS NOT NULL OR r.blocked = TRUE OR r.archived = TRUE";
private final RecipientMergeHandler recipientMergeHandler;
private final SelfAddressProvider selfAddressProvider;
@ -332,7 +332,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
public List<Pair<RecipientId, Contact>> getContacts() {
final var sql = (
"""
SELECT r._id, r.given_name, r.family_name, r.nick_name, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp
SELECT r._id, r.given_name, r.family_name, r.nick_name, r.nick_name_given_name, r.nick_name_family_name, r.note, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp
FROM %s r
WHERE (r.number IS NOT NULL OR r.aci IS NOT NULL) AND %s AND r.hidden = FALSE
"""
@ -356,7 +356,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
SELECT r._id,
r.number, r.aci, r.pni, r.username,
r.profile_key, r.profile_key_credential,
r.given_name, r.family_name, r.nick_name, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp,
r.given_name, r.family_name, r.nick_name, r.nick_name_given_name, r.nick_name_family_name, r.note, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp,
r.profile_last_update_timestamp, r.profile_given_name, r.profile_family_name, r.profile_about, r.profile_about_emoji, r.profile_avatar_url_path, r.profile_mobile_coin_address, r.profile_unidentified_access_mode, r.profile_capabilities, r.profile_phone_number_sharing,
r.discoverable,
r.storage_record
@ -376,7 +376,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
SELECT r._id,
r.number, r.aci, r.pni, r.username,
r.profile_key, r.profile_key_credential,
r.given_name, r.family_name, r.nick_name, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp,
r.given_name, r.family_name, r.nick_name, r.nick_name_given_name, r.nick_name_family_name, r.note, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp,
r.profile_last_update_timestamp, r.profile_given_name, r.profile_family_name, r.profile_about, r.profile_about_emoji, r.profile_avatar_url_path, r.profile_mobile_coin_address, r.profile_unidentified_access_mode, r.profile_capabilities, r.profile_phone_number_sharing,
r.discoverable,
r.storage_record
@ -413,7 +413,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
SELECT r._id,
r.number, r.aci, r.pni, r.username,
r.profile_key, r.profile_key_credential,
r.given_name, r.family_name, r.nick_name, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp,
r.given_name, r.family_name, r.nick_name, r.nick_name_given_name, r.nick_name_family_name, r.note, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp,
r.profile_last_update_timestamp, r.profile_given_name, r.profile_family_name, r.profile_about, r.profile_about_emoji, r.profile_avatar_url_path, r.profile_mobile_coin_address, r.profile_unidentified_access_mode, r.profile_capabilities, r.profile_phone_number_sharing,
r.discoverable,
r.storage_record
@ -817,7 +817,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
final var sql = (
"""
UPDATE %s
SET given_name = ?, family_name = ?, nick_name = ?, expiration_time = ?, mute_until = ?, hide_story = ?, profile_sharing = ?, color = ?, blocked = ?, archived = ?, unregistered_timestamp = ?
SET given_name = ?, family_name = ?, nick_name = ?, expiration_time = ?, mute_until = ?, hide_story = ?, profile_sharing = ?, color = ?, blocked = ?, archived = ?, unregistered_timestamp = ?, nick_name_given_name = ?, nick_name_family_name = ?, note = ?
WHERE _id = ?
"""
).formatted(TABLE_RECIPIENT);
@ -837,7 +837,10 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
} else {
statement.setLong(11, contact.unregisteredTimestamp());
}
statement.setLong(12, recipientId.id());
statement.setString(12, contact == null ? null : contact.nickNameGivenName());
statement.setString(13, contact == null ? null : contact.nickNameFamilyName());
statement.setString(14, contact == null ? null : contact.note());
statement.setLong(15, recipientId.id());
statement.executeUpdate();
}
if (contact != null && contact.unregisteredTimestamp() != null) {
@ -1410,7 +1413,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
private Contact getContact(final Connection connection, final RecipientId recipientId) throws SQLException {
final var sql = (
"""
SELECT r.given_name, r.family_name, r.nick_name, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp
SELECT r.given_name, r.family_name, r.nick_name, r.nick_name_given_name, r.nick_name_family_name, r.note, r.expiration_time, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.archived, r.hidden, r.unregistered_timestamp
FROM %s r
WHERE r._id = ? AND (%s)
"""

View file

@ -250,6 +250,9 @@ public class ContactRecordProcessor extends DefaultStorageRecordProcessor<Signal
final var contactGivenName = contact == null ? null : contact.givenName();
final var contactFamilyName = contact == null ? null : contact.familyName();
final var contactNickName = contact == null ? null : contact.nickName();
final var contactNickGivenName = contact == null ? null : contact.nickNameGivenName();
final var contactNickFamilyName = contact == null ? null : contact.nickNameFamilyName();
final var contactNote = contact == null ? null : contact.note();
if (blocked != contactRecord.isBlocked()
|| profileShared != contactRecord.isProfileSharingEnabled()
|| archived != contactRecord.isArchived()
@ -259,7 +262,10 @@ public class ContactRecordProcessor extends DefaultStorageRecordProcessor<Signal
|| unregisteredTimestamp != contactRecord.getUnregisteredTimestamp()
|| !Objects.equals(contactRecord.getSystemGivenName().orElse(null), contactGivenName)
|| !Objects.equals(contactRecord.getSystemFamilyName().orElse(null), contactFamilyName)
|| !Objects.equals(contactRecord.getSystemNickname().orElse(null), contactNickName)) {
|| !Objects.equals(contactRecord.getSystemNickname().orElse(null), contactNickName)
|| !Objects.equals(contactRecord.getNicknameGivenName().orElse(null), contactNickGivenName)
|| !Objects.equals(contactRecord.getNicknameFamilyName().orElse(null), contactNickFamilyName)
|| !Objects.equals(contactRecord.getNote().orElse(null), contactNote)) {
logger.debug("Storing new or updated contact {}", recipientId);
final var contactBuilder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
final var newContact = contactBuilder.withIsBlocked(contactRecord.isBlocked())

View file

@ -97,8 +97,12 @@ public final class StorageSyncModels {
builder.setSystemGivenName(recipient.getContact().givenName())
.setSystemFamilyName(recipient.getContact().familyName())
.setSystemNickname(recipient.getContact().nickName())
.setNicknameGivenName(recipient.getContact().nickNameGivenName())
.setNicknameFamilyName(recipient.getContact().nickNameFamilyName())
.setNicknameGivenName(recipient.getContact().nickNameGivenName() == null
? ""
: recipient.getContact().nickNameGivenName())
.setNicknameFamilyName(recipient.getContact().nickNameFamilyName() == null
? ""
: recipient.getContact().nickNameFamilyName())
.setNote(recipient.getContact().note())
.setBlocked(recipient.getContact().isBlocked())
.setProfileSharingEnabled(recipient.getContact().isProfileSharingEnabled())