package org.asamk.signal.json;
-import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
-import org.whispersystems.util.Base64;
+import org.asamk.signal.manager.api.MessageEnvelope;
-public class JsonSticker {
+import java.util.Base64;
- String packId;
- String packKey;
- int stickerId;
+public record JsonSticker(String packId, String packKey, int stickerId) {
- public JsonSticker(SignalServiceDataMessage.Sticker sticker) {
- this.packId = Base64.encodeBytes(sticker.getPackId());
- this.packKey = Base64.encodeBytes(sticker.getPackKey());
- this.stickerId = sticker.getStickerId();
- // TODO also download sticker image ??
+ static JsonSticker from(MessageEnvelope.Data.Sticker sticker) {
+ final var encoder = Base64.getEncoder();
+ final var packId = encoder.encodeToString(sticker.packId());
+ final var packKey = encoder.encodeToString(sticker.packKey());
+ final var stickerId = sticker.stickerId();
+ return new JsonSticker(packId, packKey, stickerId);
}
}