package org.asamk.signal.json;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import org.asamk.signal.manager.api.MessageEnvelope;
+import org.asamk.signal.util.Hex;
-import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
+public record JsonSticker(String packId, int stickerId) {
-import java.util.Base64;
-
-public class JsonSticker {
-
- @JsonProperty
- final String packId;
-
- @JsonProperty
- final String packKey;
-
- @JsonProperty
- final int stickerId;
-
- public JsonSticker(SignalServiceDataMessage.Sticker sticker) {
- this.packId = Base64.getEncoder().encodeToString(sticker.getPackId());
- this.packKey = Base64.getEncoder().encodeToString(sticker.getPackKey());
- this.stickerId = sticker.getStickerId();
+ static JsonSticker from(MessageEnvelope.Data.Sticker sticker) {
+ final var packId = Hex.toStringCondensed(sticker.packId().serialize());
+ final var stickerId = sticker.stickerId();
+ return new JsonSticker(packId, stickerId);
}
}