X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/58db3cbd53f3faec94ddfcd5e029865a380e6242..ce7aa580b6f0580cdcf7fd68fcc8efba737d21ed:/src/main/java/org/asamk/signal/json/JsonReaction.java diff --git a/src/main/java/org/asamk/signal/json/JsonReaction.java b/src/main/java/org/asamk/signal/json/JsonReaction.java index 5e978fe0..9dc64591 100644 --- a/src/main/java/org/asamk/signal/json/JsonReaction.java +++ b/src/main/java/org/asamk/signal/json/JsonReaction.java @@ -3,17 +3,30 @@ package org.asamk.signal.json; import org.asamk.signal.manager.Manager; import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Reaction; -public class JsonReaction { +import static org.asamk.signal.util.Util.getLegacyIdentifier; - String emoji; - String targetAuthor; - long targetSentTimestamp; - boolean isRemove; +public record JsonReaction( + String emoji, + @Deprecated String targetAuthor, + String targetAuthorNumber, + String targetAuthorUuid, + long targetSentTimestamp, + boolean isRemove +) { - JsonReaction(Reaction reaction, Manager m) { - this.emoji = reaction.getEmoji(); - this.targetAuthor = m.resolveSignalServiceAddress(reaction.getTargetAuthor()).getLegacyIdentifier(); - this.targetSentTimestamp = reaction.getTargetSentTimestamp(); - this.isRemove = reaction.isRemove(); + static JsonReaction from(Reaction reaction, Manager m) { + final var emoji = reaction.getEmoji(); + final var address = m.resolveSignalServiceAddress(reaction.getTargetAuthor()); + final var targetAuthor = getLegacyIdentifier(address); + final var targetAuthorNumber = address.getNumber().orNull(); + final var targetAuthorUuid = address.getUuid().toString(); + final var targetSentTimestamp = reaction.getTargetSentTimestamp(); + final var isRemove = reaction.isRemove(); + return new JsonReaction(emoji, + targetAuthor, + targetAuthorNumber, + targetAuthorUuid, + targetSentTimestamp, + isRemove); } }