-class JsonDataMessage {
-
- @JsonProperty
- final long timestamp;
-
- @JsonProperty
- final String message;
-
- @JsonProperty
- final Integer expiresInSeconds;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final Boolean viewOnce;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final JsonReaction reaction;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final JsonQuote quote;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final List<JsonMention> mentions;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final List<JsonAttachment> attachments;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final JsonSticker sticker;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final JsonRemoteDelete remoteDelete;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final List<JsonSharedContact> contacts;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final JsonGroupInfo groupInfo;
-
- JsonDataMessage(SignalServiceDataMessage dataMessage, Manager m) {
- this.timestamp = dataMessage.getTimestamp();
- if (dataMessage.getGroupContext().isPresent()) {
- final var groupContext = dataMessage.getGroupContext().get();
- if (groupContext.getGroupV1().isPresent()) {
- var groupInfo = groupContext.getGroupV1().get();
- this.groupInfo = new JsonGroupInfo(groupInfo);
- } else if (groupContext.getGroupV2().isPresent()) {
- var groupInfo = groupContext.getGroupV2().get();
- this.groupInfo = new JsonGroupInfo(groupInfo);
- } else {
- this.groupInfo = null;
- }
- } else {
- this.groupInfo = null;
- }
- this.message = dataMessage.getBody().orNull();
- this.expiresInSeconds = dataMessage.getExpiresInSeconds();
- this.viewOnce = dataMessage.isViewOnce();
- this.reaction = dataMessage.getReaction().isPresent()
- ? new JsonReaction(dataMessage.getReaction().get(), m)
- : null;
- this.quote = dataMessage.getQuote().isPresent() ? new JsonQuote(dataMessage.getQuote().get(), m) : null;
- if (dataMessage.getMentions().isPresent()) {
- this.mentions = dataMessage.getMentions()
- .get()
- .stream()
- .map(mention -> new JsonMention(mention, m))
- .collect(Collectors.toList());
- } else {
- this.mentions = List.of();
- }
- remoteDelete = dataMessage.getRemoteDelete().isPresent() ? new JsonRemoteDelete(dataMessage.getRemoteDelete()
+record JsonDataMessage(
+ long timestamp,
+ String message,
+ Integer expiresInSeconds,
+ @JsonInclude(JsonInclude.Include.NON_NULL) Boolean viewOnce,
+ @JsonInclude(JsonInclude.Include.NON_NULL) JsonReaction reaction,
+ @JsonInclude(JsonInclude.Include.NON_NULL) JsonQuote quote,
+ @JsonInclude(JsonInclude.Include.NON_NULL) JsonPayment payment,
+ @JsonInclude(JsonInclude.Include.NON_NULL) List<JsonMention> mentions,
+ @JsonInclude(JsonInclude.Include.NON_NULL) List<JsonPreview> previews,
+ @JsonInclude(JsonInclude.Include.NON_NULL) List<JsonAttachment> attachments,
+ @JsonInclude(JsonInclude.Include.NON_NULL) JsonSticker sticker,
+ @JsonInclude(JsonInclude.Include.NON_NULL) JsonRemoteDelete remoteDelete,
+ @JsonInclude(JsonInclude.Include.NON_NULL) List<JsonSharedContact> contacts,
+ @JsonInclude(JsonInclude.Include.NON_NULL) JsonGroupInfo groupInfo,
+ @JsonInclude(JsonInclude.Include.NON_NULL) JsonStoryContext storyContext
+) {
+
+ static JsonDataMessage from(MessageEnvelope.Data dataMessage) {
+ final var timestamp = dataMessage.timestamp();
+ final var groupInfo = dataMessage.groupContext().isPresent() ? JsonGroupInfo.from(dataMessage.groupContext()