]> nmode's Git Repositories - signal-cli/commitdiff
Add missing parts for new nick name and note columns
authorAsamK <asamk@gmx.de>
Wed, 17 Apr 2024 18:50:03 +0000 (20:50 +0200)
committerAsamK <asamk@gmx.de>
Wed, 17 Apr 2024 19:21:28 +0000 (21:21 +0200)
lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java
lib/src/main/java/org/asamk/signal/manager/syncStorage/ContactRecordProcessor.java
lib/src/main/java/org/asamk/signal/manager/syncStorage/StorageSyncModels.java

index 6428d20216187cb61a60522748b9378998bd7066..31a5a963d75e8215c5be9f845d89efa7716bd25a 100644 (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 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;
 
     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 = (
                 """
     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
                 """
                 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,
                 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
                        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,
                 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
                        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,
                 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
                        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
         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);
                 WHERE _id = ?
                 """
         ).formatted(TABLE_RECIPIENT);
@@ -837,7 +837,10 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
             } else {
                 statement.setLong(11, contact.unregisteredTimestamp());
             }
             } 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) {
             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 = (
                 """
     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)
                 """
                 FROM %s r
                 WHERE r._id = ? AND (%s)
                 """
index a087553be69efc999bd2a3fa4c43a4ec3996aa70..72ee41638947d8e3ecc8b7b26c99c7372a26d13f 100644 (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 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()
         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)
                 || 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())
             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())
index 16733bee7ad34fd82e021e88b634ddf09bd9a566..ecb97bdff48ced99500a5b4ae9d87eeab1311089 100644 (file)
@@ -97,8 +97,12 @@ public final class StorageSyncModels {
             builder.setSystemGivenName(recipient.getContact().givenName())
                     .setSystemFamilyName(recipient.getContact().familyName())
                     .setSystemNickname(recipient.getContact().nickName())
             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())
                     .setNote(recipient.getContact().note())
                     .setBlocked(recipient.getContact().isBlocked())
                     .setProfileSharingEnabled(recipient.getContact().isProfileSharingEnabled())