Skip to content

Commit

Permalink
add received and delivered timestamps on json message
Browse files Browse the repository at this point in the history
  • Loading branch information
Jailson Dias committed Oct 24, 2024
1 parent fab1b96 commit 88e296e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/main/java/org/asamk/signal/json/JsonMessageEnvelope.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public record JsonMessageEnvelope(
String sourceName,
Integer sourceDevice,
long timestamp,
long serverReceivedTimestamp,
long serverDeliveredTimestamp,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonDataMessage dataMessage,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonEditMessage editMessage,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonStoryMessage storyMessage,
Expand Down Expand Up @@ -58,13 +60,21 @@ public static JsonMessageEnvelope from(
sourceName = null;
}
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 typingMessage = envelope.typing().map(JsonTypingMessage::from).orElse(null);

final var dataMessage = envelope.data().map(JsonDataMessage::from).orElse(null);
final var editMessage = envelope.edit().map(JsonEditMessage::from).orElse(null);
final var dataMessage = envelope.data()
.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 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);

return new JsonMessageEnvelope(source,
Expand All @@ -73,6 +83,8 @@ public static JsonMessageEnvelope from(
sourceName,
sourceDevice,
timestamp,
serverReceivedTimestamp,
serverDeliveredTimestamp,
dataMessage,
editMessage,
storyMessage,
Expand Down

0 comments on commit 88e296e

Please sign in to comment.