Extend json output with number and uuid fields

This commit is contained in:
AsamK 2021-08-22 11:28:09 +02:00
parent 73e137137d
commit 5bbfd32598
9 changed files with 148 additions and 32 deletions

View file

@ -5,6 +5,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.asamk.signal.manager.Manager;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Reaction;
import java.util.UUID;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
public class JsonReaction {
@ -13,8 +15,15 @@ public class JsonReaction {
final String emoji;
@JsonProperty
@Deprecated
final String targetAuthor;
@JsonProperty
final String targetAuthorNumber;
@JsonProperty
final String targetAuthorUuid;
@JsonProperty
final long targetSentTimestamp;
@ -23,7 +32,10 @@ public class JsonReaction {
JsonReaction(Reaction reaction, Manager m) {
this.emoji = reaction.getEmoji();
this.targetAuthor = getLegacyIdentifier(m.resolveSignalServiceAddress(reaction.getTargetAuthor()));
final var address = m.resolveSignalServiceAddress(reaction.getTargetAuthor());
this.targetAuthor = getLegacyIdentifier(address);
this.targetAuthorNumber = address.getNumber().orNull();
this.targetAuthorUuid = address.getUuid().transform(UUID::toString).orNull();
this.targetSentTimestamp = reaction.getTargetSentTimestamp();
this.isRemove = reaction.isRemove();
}