add received and delivered timestamps on json message

This commit is contained in:
Jailson Dias 2024-10-24 17:27:18 -03:00 committed by Sebastian Scheibner
parent fab1b96c21
commit 5646f65195

View file

@ -17,6 +17,8 @@ public record JsonMessageEnvelope(
String sourceName, String sourceName,
Integer sourceDevice, Integer sourceDevice,
long timestamp, long timestamp,
long serverReceivedTimestamp,
long serverDeliveredTimestamp,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonDataMessage dataMessage, @JsonInclude(JsonInclude.Include.NON_NULL) JsonDataMessage dataMessage,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonEditMessage editMessage, @JsonInclude(JsonInclude.Include.NON_NULL) JsonEditMessage editMessage,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonStoryMessage storyMessage, @JsonInclude(JsonInclude.Include.NON_NULL) JsonStoryMessage storyMessage,
@ -58,13 +60,21 @@ public record JsonMessageEnvelope(
sourceName = null; sourceName = null;
} }
final var timestamp = envelope.timestamp(); final var timestamp = envelope.timestamp();
final var serverReceivedTimestamp = envelope.serverReceivedTimestamp();
final var serverDeliveredTimestamp = envelope.serverDeliveredTimestamp();
final var receiptMessage = envelope.receipt().map(JsonReceiptMessage::from).orElse(null); final var receiptMessage = envelope.receipt().map(JsonReceiptMessage::from).orElse(null);
final var typingMessage = envelope.typing().map(JsonTypingMessage::from).orElse(null); final var typingMessage = envelope.typing().map(JsonTypingMessage::from).orElse(null);
final var dataMessage = envelope.data().map(JsonDataMessage::from).orElse(null); final var dataMessage = envelope.data()
final var editMessage = envelope.edit().map(JsonEditMessage::from).orElse(null); .map(data -> JsonDataMessage.from(data, m))
.orElse(null);
final var editMessage = envelope.edit()
.map(data -> JsonEditMessage.from(data, m))
.orElse(null);
final var storyMessage = envelope.story().map(JsonStoryMessage::from).orElse(null); final var storyMessage = envelope.story().map(JsonStoryMessage::from).orElse(null);
final var syncMessage = envelope.sync().map(JsonSyncMessage::from).orElse(null); final var syncMessage = envelope.sync()
.map(data -> JsonSyncMessage.from(data, m))
.orElse(null);
final var callMessage = envelope.call().map(JsonCallMessage::from).orElse(null); final var callMessage = envelope.call().map(JsonCallMessage::from).orElse(null);
return new JsonMessageEnvelope(source, return new JsonMessageEnvelope(source,
@ -73,6 +83,8 @@ public record JsonMessageEnvelope(
sourceName, sourceName,
sourceDevice, sourceDevice,
timestamp, timestamp,
serverReceivedTimestamp,
serverDeliveredTimestamp,
dataMessage, dataMessage,
editMessage, editMessage,
storyMessage, storyMessage,