1 package org
.asamk
.signal
.json
;
3 import com
.fasterxml
.jackson
.annotation
.JsonInclude
;
5 import org
.asamk
.signal
.manager
.Manager
;
6 import org
.asamk
.signal
.manager
.api
.MessageEnvelope
;
10 record JsonDataMessage(
13 Integer expiresInSeconds
,
14 @JsonInclude(JsonInclude
.Include
.NON_NULL
) Boolean viewOnce
,
15 @JsonInclude(JsonInclude
.Include
.NON_NULL
) JsonReaction reaction
,
16 @JsonInclude(JsonInclude
.Include
.NON_NULL
) JsonQuote quote
,
17 @JsonInclude(JsonInclude
.Include
.NON_NULL
) JsonPayment payment
,
18 @JsonInclude(JsonInclude
.Include
.NON_NULL
) List
<JsonMention
> mentions
,
19 @JsonInclude(JsonInclude
.Include
.NON_NULL
) List
<JsonPreview
> previews
,
20 @JsonInclude(JsonInclude
.Include
.NON_NULL
) List
<JsonAttachment
> attachments
,
21 @JsonInclude(JsonInclude
.Include
.NON_NULL
) JsonSticker sticker
,
22 @JsonInclude(JsonInclude
.Include
.NON_NULL
) JsonRemoteDelete remoteDelete
,
23 @JsonInclude(JsonInclude
.Include
.NON_NULL
) List
<JsonSharedContact
> contacts
,
24 @JsonInclude(JsonInclude
.Include
.NON_NULL
) List
<JsonTextStyle
> textStyles
,
25 @JsonInclude(JsonInclude
.Include
.NON_NULL
) JsonGroupInfo groupInfo
,
26 @JsonInclude(JsonInclude
.Include
.NON_NULL
) JsonStoryContext storyContext
29 static JsonDataMessage
from(MessageEnvelope
.Data dataMessage
, Manager m
) {
30 final var timestamp
= dataMessage
.timestamp();
31 final var groupInfo
= dataMessage
.groupContext().isPresent() ? JsonGroupInfo
.from(dataMessage
.groupContext()
33 final var storyContext
= dataMessage
.storyContext().isPresent()
34 ? JsonStoryContext
.from(dataMessage
.storyContext().get())
36 final var message
= dataMessage
.body().orElse(null);
37 final var expiresInSeconds
= dataMessage
.expiresInSeconds();
38 final var viewOnce
= dataMessage
.isViewOnce();
39 final var reaction
= dataMessage
.reaction().map(JsonReaction
::from
).orElse(null);
40 final var quote
= dataMessage
.quote().isPresent() ? JsonQuote
.from(dataMessage
.quote().get()) : null;
41 final var payment
= dataMessage
.payment().isPresent() ? JsonPayment
.from(dataMessage
.payment().get()) : null;
42 final var mentions
= !dataMessage
.mentions().isEmpty() ? dataMessage
.mentions()
44 .map(JsonMention
::from
)
46 final var previews
= !dataMessage
.previews().isEmpty() ? dataMessage
.previews()
48 .map(JsonPreview
::from
)
50 final var remoteDelete
= dataMessage
.remoteDeleteId().isPresent()
51 ?
new JsonRemoteDelete(dataMessage
.remoteDeleteId().get())
53 final var attachments
= !dataMessage
.attachments().isEmpty() ? dataMessage
.attachments()
55 .map(JsonAttachment
::from
)
57 final var sticker
= dataMessage
.sticker().isPresent() ? JsonSticker
.from(dataMessage
.sticker().get()) : null;
58 final var contacts
= !dataMessage
.sharedContacts().isEmpty() ? dataMessage
.sharedContacts()
60 .map(JsonSharedContact
::from
)
62 final var textStyles
= !dataMessage
.textStyles().isEmpty() ? dataMessage
.textStyles()
64 .map(JsonTextStyle
::from
)
67 return new JsonDataMessage(timestamp
,