- JsonDataMessage(SignalServiceDataMessage dataMessage, Manager m) {
- this.timestamp = dataMessage.getTimestamp();
- if (dataMessage.getGroupContext().isPresent()) {
- if (dataMessage.getGroupContext().get().getGroupV1().isPresent()) {
- SignalServiceGroup groupInfo = dataMessage.getGroupContext().get().getGroupV1().get();
- this.groupInfo = new JsonGroupInfo(groupInfo);
- } else if (dataMessage.getGroupContext().get().getGroupV2().isPresent()) {
- SignalServiceGroupV2 groupInfo = dataMessage.getGroupContext().get().getGroupV2().get();
- this.groupInfo = new JsonGroupInfo(groupInfo);
- }
- }
- if (dataMessage.getBody().isPresent()) {
- this.message = dataMessage.getBody().get();
- }
- this.expiresInSeconds = dataMessage.getExpiresInSeconds();
- if (dataMessage.getReaction().isPresent()) {
- this.reaction = new JsonReaction(dataMessage.getReaction().get(), m);
- }
- if (dataMessage.getQuote().isPresent()) {
- this.quote = new JsonQuote(dataMessage.getQuote().get(), m);
- }
- if (dataMessage.getMentions().isPresent()) {
- this.mentions = dataMessage.getMentions()
- .get()
- .stream()
- .map(mention -> new JsonMention(mention, m))
- .collect(Collectors.toList());
- } else {
- this.mentions = List.of();
- }
- if (dataMessage.getAttachments().isPresent()) {
- this.attachments = dataMessage.getAttachments()
- .get()
- .stream()
- .map(JsonAttachment::new)
- .collect(Collectors.toList());
- } else {
- this.attachments = List.of();
- }
- if (dataMessage.getSticker().isPresent()) {
- this.sticker = new JsonSticker(dataMessage.getSticker().get());
- }
- }
+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<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
+) {