From 2a8a141e9ea948a092def6ebc45eb735ea23bff1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Nov 2026 04:33:31 -0500 Subject: [PATCH] Expose profile badges in listContacts (#2162) * Expose profile badges in listContacts Closes #2161 Co-Authored-By: Claude Opus 5.5 * Add changelog entry for profile badges Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- CHANGELOG.md | 4 ++ .../org/asamk/signal/manager/api/Profile.java | 32 +++++++++- .../manager/storage/AccountDatabase.java | 10 +++- .../signal/manager/storage/SignalAccount.java | 3 +- .../recipients/LegacyRecipientStore2.java | 3 +- .../storage/recipients/RecipientStore.java | 58 ++++++++++++++++--- .../signal/manager/util/ProfileUtils.java | 22 ++++++- .../recipients/RecipientStoreTest.java | 23 ++++++++ .../signal/manager/util/ProfileUtilsTest.java | 52 +++++++++++++++++ .../signal/commands/ListContactsCommand.java | 13 ++++- .../org/asamk/signal/json/JsonContact.java | 6 +- .../signal-cli/reachability-metadata.json | 26 +++++++++ 12 files changed, 234 insertions(+), 18 deletions(-) create mode 100644 lib/src/test/java/org/asamk/signal/manager/util/ProfileUtilsTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e99fee7..4598e6d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- Include profile badges (e.g. donor badges) in `listContacts` output + ## [0.14.9] - 2026-10-07 ### Added diff --git a/lib/src/main/java/org/asamk/signal/manager/api/Profile.java b/lib/src/main/java/org/asamk/signal/manager/api/Profile.java index acbaac11..d4106d13 100644 --- a/lib/src/main/java/org/asamk/signal/manager/api/Profile.java +++ b/lib/src/main/java/org/asamk/signal/manager/api/Profile.java @@ -3,6 +3,7 @@ package org.asamk.signal.manager.api; import org.whispersystems.signalservice.internal.util.Util; import java.util.Collections; +import java.util.List; import java.util.Objects; import java.util.Set; @@ -28,6 +29,8 @@ public class Profile { private final PhoneNumberSharingMode phoneNumberSharingMode; + private final List badges; + public Profile( final long lastUpdateTimestamp, final String givenName, @@ -38,7 +41,8 @@ public class Profile { final byte[] mobileCoinAddress, final UnidentifiedAccessMode unidentifiedAccessMode, final Set capabilities, - final PhoneNumberSharingMode phoneNumberSharingMode + final PhoneNumberSharingMode phoneNumberSharingMode, + final List badges ) { this.lastUpdateTimestamp = lastUpdateTimestamp; this.givenName = givenName; @@ -50,6 +54,7 @@ public class Profile { this.unidentifiedAccessMode = unidentifiedAccessMode; this.capabilities = capabilities; this.phoneNumberSharingMode = phoneNumberSharingMode; + this.badges = badges == null ? List.of() : List.copyOf(badges); } private Profile(final Builder builder) { @@ -63,6 +68,7 @@ public class Profile { unidentifiedAccessMode = builder.unidentifiedAccessMode; capabilities = builder.capabilities; phoneNumberSharingMode = builder.phoneNumberSharingMode; + badges = builder.badges; } public static Builder newBuilder() { @@ -80,6 +86,7 @@ public class Profile { builder.mobileCoinAddress = copy.getMobileCoinAddress(); builder.unidentifiedAccessMode = copy.getUnidentifiedAccessMode(); builder.capabilities = copy.getCapabilities(); + builder.badges = copy.getBadges(); return builder; } @@ -145,6 +152,10 @@ public class Profile { return phoneNumberSharingMode; } + public List getBadges() { + return badges; + } + public enum UnidentifiedAccessMode { UNKNOWN, DISABLED, @@ -173,6 +184,13 @@ public class Profile { } } + /** + * A badge displayed on a profile, e.g. a donor badge. + * + * @param expirationTimestamp the time in milliseconds when the badge expires, or null if it doesn't expire + */ + public record Badge(String id, String category, Long expirationTimestamp, boolean visible) {} + @Override public boolean equals(final Object o) { if (this == o) return true; @@ -185,7 +203,8 @@ public class Profile { && Objects.equals(aboutEmoji, profile.aboutEmoji) && Objects.equals(avatarUrlPath, profile.avatarUrlPath) && unidentifiedAccessMode == profile.unidentifiedAccessMode - && Objects.equals(capabilities, profile.capabilities); + && Objects.equals(capabilities, profile.capabilities) + && Objects.equals(badges, profile.badges); } @Override @@ -197,7 +216,8 @@ public class Profile { aboutEmoji, avatarUrlPath, unidentifiedAccessMode, - capabilities); + capabilities, + badges); } public static final class Builder { @@ -211,6 +231,7 @@ public class Profile { private UnidentifiedAccessMode unidentifiedAccessMode = UnidentifiedAccessMode.UNKNOWN; private Set capabilities = Collections.emptySet(); private PhoneNumberSharingMode phoneNumberSharingMode; + private List badges = List.of(); private long lastUpdateTimestamp = 0; private Builder() { @@ -256,6 +277,11 @@ public class Profile { return this; } + public Builder withBadges(final List val) { + badges = val == null ? List.of() : List.copyOf(val); + return this; + } + public Profile build() { return new Profile(this); } diff --git a/lib/src/main/java/org/asamk/signal/manager/storage/AccountDatabase.java b/lib/src/main/java/org/asamk/signal/manager/storage/AccountDatabase.java index 105422ab..700d7fab 100644 --- a/lib/src/main/java/org/asamk/signal/manager/storage/AccountDatabase.java +++ b/lib/src/main/java/org/asamk/signal/manager/storage/AccountDatabase.java @@ -33,7 +33,7 @@ import java.util.UUID; public class AccountDatabase extends Database { private static final Logger logger = LoggerFactory.getLogger(AccountDatabase.class); - private static final long DATABASE_VERSION = 31; + private static final long DATABASE_VERSION = 32; private AccountDatabase(final HikariDataSource dataSource) { super(logger, DATABASE_VERSION, dataSource); @@ -653,6 +653,14 @@ public class AccountDatabase extends Database { """); } } + if (oldVersion < 32) { + logger.debug("Updating database: Create profile_badges column"); + try (final var statement = connection.createStatement()) { + statement.executeUpdate(""" + ALTER TABLE recipient ADD profile_badges TEXT; + """); + } + } } private static void createUuidMappingTable( diff --git a/lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java b/lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java index 560b5de7..7f73452f 100644 --- a/lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java +++ b/lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java @@ -1035,7 +1035,8 @@ public class SignalAccount implements Closeable { ? Profile.UnidentifiedAccessMode.ENABLED : Profile.UnidentifiedAccessMode.DISABLED, capabilities, - null); + null, + List.of()); getProfileStore().storeProfile(recipientId, newProfile); } } diff --git a/lib/src/main/java/org/asamk/signal/manager/storage/recipients/LegacyRecipientStore2.java b/lib/src/main/java/org/asamk/signal/manager/storage/recipients/LegacyRecipientStore2.java index eea5b973..a7987657 100644 --- a/lib/src/main/java/org/asamk/signal/manager/storage/recipients/LegacyRecipientStore2.java +++ b/lib/src/main/java/org/asamk/signal/manager/storage/recipients/LegacyRecipientStore2.java @@ -90,7 +90,8 @@ public class LegacyRecipientStore2 { .map(Profile.Capability::valueOfOrNull) .filter(Objects::nonNull) .collect(Collectors.toSet()), - null); + null, + List.of()); } return new Recipient(recipientId, diff --git a/lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java b/lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java index 195b5735..bdab2a7f 100644 --- a/lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java +++ b/lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java @@ -1,5 +1,7 @@ package org.asamk.signal.manager.storage.recipients; +import com.fasterxml.jackson.databind.ObjectMapper; + import org.asamk.signal.manager.api.Contact; import org.asamk.signal.manager.api.Pair; import org.asamk.signal.manager.api.PhoneNumberSharingMode; @@ -21,6 +23,7 @@ import org.slf4j.LoggerFactory; import org.whispersystems.signalservice.api.push.SignalServiceAddress; import org.whispersystems.signalservice.api.storage.StorageId; +import java.io.IOException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -42,6 +45,7 @@ import java.util.stream.Collectors; public class RecipientStore implements RecipientIdCreator, RecipientResolver, RecipientTrustedResolver, ContactsStore, ProfileStore { private static final Logger logger = LoggerFactory.getLogger(RecipientStore.class); + private static final ObjectMapper objectMapper = new ObjectMapper(); 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.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"; @@ -111,7 +115,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re profile_mobile_coin_address BLOB, profile_unidentified_access_mode TEXT, profile_capabilities TEXT, - profile_phone_number_sharing TEXT + profile_phone_number_sharing TEXT, + profile_badges TEXT ) STRICT; """); } @@ -378,7 +383,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re r.profile_key, r.profile_key_credential, r.pni_signature_verified, 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.expiration_time_version, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.blocked_at, 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.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.profile_badges, r.discoverable, r.storage_record FROM %s r @@ -399,7 +404,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re r.profile_key, r.profile_key_credential, r.pni_signature_verified, 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.expiration_time_version, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.blocked_at, 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.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.profile_badges, r.discoverable, r.storage_record FROM %s r @@ -449,7 +454,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re r.profile_key, r.profile_key_credential, r.pni_signature_verified, 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.expiration_time_version, r.mute_until, r.hide_story, r.profile_sharing, r.color, r.blocked, r.blocked_at, 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.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.profile_badges, r.discoverable, r.storage_record FROM %s r @@ -1226,7 +1231,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re final var sql = ( """ UPDATE %s - SET profile_last_update_timestamp = ?, profile_given_name = ?, profile_family_name = ?, profile_about = ?, profile_about_emoji = ?, profile_avatar_url_path = ?, profile_mobile_coin_address = ?, profile_unidentified_access_mode = ?, profile_capabilities = ?, profile_phone_number_sharing = ? + SET profile_last_update_timestamp = ?, profile_given_name = ?, profile_family_name = ?, profile_about = ?, profile_about_emoji = ?, profile_avatar_url_path = ?, profile_mobile_coin_address = ?, profile_unidentified_access_mode = ?, profile_capabilities = ?, profile_phone_number_sharing = ?, profile_badges = ? WHERE _id = ? """ ).formatted(TABLE_RECIPIENT); @@ -1247,7 +1252,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re profile == null || profile.getPhoneNumberSharingMode() == null ? null : profile.getPhoneNumberSharingMode().name()); - statement.setLong(11, recipientId.id()); + statement.setString(11, profile == null ? null : serializeBadges(profile.getBadges())); + statement.setLong(12, recipientId.id()); statement.executeUpdate(); } rotateStorageId(connection, recipientId); @@ -1697,7 +1703,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re public Profile getProfile(final Connection connection, final RecipientId recipientId) throws SQLException { final var sql = ( """ - SELECT 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 + SELECT 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.profile_badges FROM %s r WHERE r._id = ? AND r.profile_capabilities IS NOT NULL """ @@ -1794,7 +1800,43 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re .map(Profile.Capability::valueOfOrNull) .filter(Objects::nonNull) .collect(Collectors.toSet()), - PhoneNumberSharingMode.valueOfOrNull(resultSet.getString("profile_phone_number_sharing"))); + PhoneNumberSharingMode.valueOfOrNull(resultSet.getString("profile_phone_number_sharing")), + deserializeBadges(resultSet.getString("profile_badges"))); + } + + static String serializeBadges(final List badges) { + if (badges.isEmpty()) { + return null; + } + final var array = objectMapper.createArrayNode(); + for (final var badge : badges) { + final var node = array.addObject(); + node.put("id", badge.id()); + node.put("category", badge.category()); + node.put("expirationTimestamp", badge.expirationTimestamp()); + node.put("visible", badge.visible()); + } + return array.toString(); + } + + static List deserializeBadges(final String badges) { + if (badges == null) { + return List.of(); + } + try { + final var result = new ArrayList(); + for (final var node : objectMapper.readTree(badges)) { + final var expirationTimestamp = node.path("expirationTimestamp"); + result.add(new Profile.Badge(node.path("id").asText(null), + node.path("category").asText(null), + expirationTimestamp.isNumber() ? expirationTimestamp.asLong() : null, + node.path("visible").asBoolean(false))); + } + return result; + } catch (IOException e) { + logger.warn("Failed to parse stored profile badges, ignoring: {}", e.getMessage()); + return List.of(); + } } private ProfileKey getProfileKeyFromResultSet(ResultSet resultSet) throws SQLException { diff --git a/lib/src/main/java/org/asamk/signal/manager/util/ProfileUtils.java b/lib/src/main/java/org/asamk/signal/manager/util/ProfileUtils.java index 4f6c3126..6b2be048 100644 --- a/lib/src/main/java/org/asamk/signal/manager/util/ProfileUtils.java +++ b/lib/src/main/java/org/asamk/signal/manager/util/ProfileUtils.java @@ -15,8 +15,11 @@ import org.whispersystems.signalservice.api.profiles.SignalServiceProfile; import org.whispersystems.signalservice.internal.push.PaymentAddress; import java.io.IOException; +import java.math.BigDecimal; import java.util.Base64; import java.util.HashSet; +import java.util.List; +import java.util.Objects; import java.util.Optional; public class ProfileUtils { @@ -54,7 +57,8 @@ public class ProfileUtils { identityKey.getPublicKey()), getUnidentifiedAccessMode(encryptedProfile, profileCipher), getCapabilities(encryptedProfile), - remotePhoneNumberSharing); + remotePhoneNumberSharing, + getBadges(encryptedProfile)); } catch (InvalidCiphertextException e) { logger.debug("Failed to decrypt profile for {}", encryptedProfile.getServiceId(), e); return null; @@ -79,6 +83,22 @@ public class ProfileUtils { return Profile.UnidentifiedAccessMode.DISABLED; } + static List getBadges(final SignalServiceProfile encryptedProfile) { + if (encryptedProfile.getBadges() == null) { + return List.of(); + } + return encryptedProfile.getBadges() + .stream() + .filter(Objects::nonNull) + .map(badge -> new Profile.Badge(badge.getId(), + badge.getCategory(), + badge.getExpiration() == null + ? null + : badge.getExpiration().multiply(BigDecimal.valueOf(1000)).longValue(), + badge.getVisible())) + .toList(); + } + public static HashSet getCapabilities(final SignalServiceProfile encryptedProfile) { final var capabilities = new HashSet(); if (encryptedProfile.getCapabilities() != null) { diff --git a/lib/src/test/java/org/asamk/signal/manager/storage/recipients/RecipientStoreTest.java b/lib/src/test/java/org/asamk/signal/manager/storage/recipients/RecipientStoreTest.java index e2ae594c..66f53795 100644 --- a/lib/src/test/java/org/asamk/signal/manager/storage/recipients/RecipientStoreTest.java +++ b/lib/src/test/java/org/asamk/signal/manager/storage/recipients/RecipientStoreTest.java @@ -1,10 +1,14 @@ package org.asamk.signal.manager.storage.recipients; import org.asamk.signal.manager.api.Contact; +import org.asamk.signal.manager.api.Profile; import org.junit.jupiter.api.Test; +import java.util.List; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; class RecipientStoreTest { @@ -90,4 +94,23 @@ class RecipientStoreTest { assertEquals(100, merged.muteUntil()); assertTrue(merged.isHidden()); } + + @Test + void profileBadgesRoundTrip() { + final var badges = List.of(new Profile.Badge("BOOST", "donor", 1767225600000L, true), + new Profile.Badge("TEST", "other", null, false)); + + assertEquals(badges, RecipientStore.deserializeBadges(RecipientStore.serializeBadges(badges))); + } + + @Test + void emptyProfileBadgesAreStoredAsNull() { + assertNull(RecipientStore.serializeBadges(List.of())); + assertEquals(List.of(), RecipientStore.deserializeBadges(null)); + } + + @Test + void invalidStoredProfileBadgesAreIgnored() { + assertEquals(List.of(), RecipientStore.deserializeBadges("not json")); + } } diff --git a/lib/src/test/java/org/asamk/signal/manager/util/ProfileUtilsTest.java b/lib/src/test/java/org/asamk/signal/manager/util/ProfileUtilsTest.java new file mode 100644 index 00000000..d5b735f4 --- /dev/null +++ b/lib/src/test/java/org/asamk/signal/manager/util/ProfileUtilsTest.java @@ -0,0 +1,52 @@ +package org.asamk.signal.manager.util; + +import org.asamk.signal.manager.api.Profile; +import org.junit.jupiter.api.Test; +import org.whispersystems.signalservice.api.profiles.SignalServiceProfile; + +import java.math.BigDecimal; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class ProfileUtilsTest { + + @Test + void badgesAreConvertedFromServiceProfile() { + final var profile = profileWithBadges(List.of(badge("BOOST", "donor", new BigDecimal("1767225600"), true), + badge("TEST", "other", null, false))); + + assertEquals(List.of(new Profile.Badge("BOOST", "donor", 1767225600000L, true), + new Profile.Badge("TEST", "other", null, false)), ProfileUtils.getBadges(profile)); + } + + @Test + void missingBadgesResultInEmptyList() { + assertEquals(List.of(), ProfileUtils.getBadges(profileWithBadges(null))); + } + + private static SignalServiceProfile.Badge badge( + final String id, + final String category, + final BigDecimal expiration, + final boolean visible + ) { + return new SignalServiceProfile.Badge(id, category, "", "", List.of(), expiration, visible, 0); + } + + private static SignalServiceProfile profileWithBadges(final List badges) { + return new SignalServiceProfile(null, + null, + null, + null, + null, + null, + null, + false, + null, + null, + null, + badges, + null); + } +} diff --git a/src/main/java/org/asamk/signal/commands/ListContactsCommand.java b/src/main/java/org/asamk/signal/commands/ListContactsCommand.java index b382e7ac..b5243ef1 100644 --- a/src/main/java/org/asamk/signal/commands/ListContactsCommand.java +++ b/src/main/java/org/asamk/signal/commands/ListContactsCommand.java @@ -82,7 +82,7 @@ public class ListContactsCommand implements JsonRpcLocalCommand { if (detailed) { writer.indentedWriter() .println( - "PNI: {} Given name: {} Family name: {}, Nick name: {} Nick given name: {} Nick family name {} Note: {} Archived: {} Hidden: {} Profile sharing: {} About: {} About Emoji: {} Unregistered: {}", + "PNI: {} Given name: {} Family name: {}, Nick name: {} Nick given name: {} Nick family name {} Note: {} Archived: {} Hidden: {} Profile sharing: {} About: {} About Emoji: {} Badges: {} Unregistered: {}", r.getAddress().pni().orElse(""), Optional.ofNullable(r.getContact().givenName()).orElse(""), Optional.ofNullable(r.getContact().familyName()).orElse(""), @@ -95,6 +95,7 @@ public class ListContactsCommand implements JsonRpcLocalCommand { r.getContact().isProfileSharingEnabled(), Optional.ofNullable(r.getProfile().getAbout()).orElse(""), Optional.ofNullable(r.getProfile().getAboutEmoji()).orElse(""), + profile.getBadges().stream().map(Profile.Badge::id).toList(), r.getContact().unregisteredTimestamp() != null); } if (internal) { @@ -161,7 +162,15 @@ public class ListContactsCommand implements JsonRpcLocalCommand { r.getProfile().getMobileCoinAddress() == null ? null : Base64.getEncoder() - .encodeToString(r.getProfile().getMobileCoinAddress())), + .encodeToString(r.getProfile().getMobileCoinAddress()), + r.getProfile() + .getBadges() + .stream() + .map(b -> new JsonContact.JsonBadge(b.id(), + b.category(), + b.expirationTimestamp(), + b.visible())) + .toList()), jsonInternal); }).toList(); writer.write(jsonContacts); diff --git a/src/main/java/org/asamk/signal/json/JsonContact.java b/src/main/java/org/asamk/signal/json/JsonContact.java index c46e6b80..1abd8ab1 100644 --- a/src/main/java/org/asamk/signal/json/JsonContact.java +++ b/src/main/java/org/asamk/signal/json/JsonContact.java @@ -37,9 +37,13 @@ public record JsonContact( String about, String aboutEmoji, boolean hasAvatar, - String mobileCoinAddress + String mobileCoinAddress, + List badges ) {} + @JsonSchema(title = "Badge") + public record JsonBadge(String id, String category, Long expirationTimestamp, boolean visible) {} + @JsonSchema(title = "Internal") public record JsonInternal( List capabilities, diff --git a/src/main/resources/META-INF/native-image/org.asamk/signal-cli/reachability-metadata.json b/src/main/resources/META-INF/native-image/org.asamk/signal-cli/reachability-metadata.json index afb981aa..2aa312ae 100644 --- a/src/main/resources/META-INF/native-image/org.asamk/signal-cli/reachability-metadata.json +++ b/src/main/resources/META-INF/native-image/org.asamk/signal-cli/reachability-metadata.json @@ -3104,6 +3104,28 @@ } ] }, + { + "type": "org.asamk.signal.json.JsonContact$JsonBadge", + "allDeclaredFields": true, + "methods": [ + { + "name": "category", + "parameterTypes": [] + }, + { + "name": "expirationTimestamp", + "parameterTypes": [] + }, + { + "name": "id", + "parameterTypes": [] + }, + { + "name": "visible", + "parameterTypes": [] + } + ] + }, { "type": "org.asamk.signal.json.JsonContact$JsonInternal", "allDeclaredFields": true, @@ -3138,6 +3160,10 @@ "name": "aboutEmoji", "parameterTypes": [] }, + { + "name": "badges", + "parameterTypes": [] + }, { "name": "familyName", "parameterTypes": []