mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Adapt json output to always use receiptMessage and remove isReceipt field
Fixes #346
This commit is contained in:
parent
a634b46eb2
commit
4485188789
2 changed files with 17 additions and 3 deletions
|
@ -5,13 +5,14 @@ import org.whispersystems.signalservice.api.messages.SignalServiceContent;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class JsonMessageEnvelope {
|
public class JsonMessageEnvelope {
|
||||||
|
|
||||||
String source;
|
String source;
|
||||||
int sourceDevice;
|
int sourceDevice;
|
||||||
String relay;
|
String relay;
|
||||||
long timestamp;
|
long timestamp;
|
||||||
boolean isReceipt;
|
|
||||||
JsonDataMessage dataMessage;
|
JsonDataMessage dataMessage;
|
||||||
JsonSyncMessage syncMessage;
|
JsonSyncMessage syncMessage;
|
||||||
JsonCallMessage callMessage;
|
JsonCallMessage callMessage;
|
||||||
|
@ -25,7 +26,9 @@ public class JsonMessageEnvelope {
|
||||||
}
|
}
|
||||||
this.sourceDevice = envelope.getSourceDevice();
|
this.sourceDevice = envelope.getSourceDevice();
|
||||||
this.timestamp = envelope.getTimestamp();
|
this.timestamp = envelope.getTimestamp();
|
||||||
this.isReceipt = envelope.isReceipt();
|
if (envelope.isReceipt()) {
|
||||||
|
this.receiptMessage = JsonReceiptMessage.deliveryReceipt(timestamp, List.of(timestamp));
|
||||||
|
}
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
if (envelope.isUnidentifiedSender()) {
|
if (envelope.isUnidentifiedSender()) {
|
||||||
this.source = content.getSender().getLegacyIdentifier();
|
this.source = content.getSender().getLegacyIdentifier();
|
||||||
|
@ -55,7 +58,7 @@ public class JsonMessageEnvelope {
|
||||||
public JsonMessageEnvelope(Signal.ReceiptReceived receiptReceived) {
|
public JsonMessageEnvelope(Signal.ReceiptReceived receiptReceived) {
|
||||||
source = receiptReceived.getSender();
|
source = receiptReceived.getSender();
|
||||||
timestamp = receiptReceived.getTimestamp();
|
timestamp = receiptReceived.getTimestamp();
|
||||||
isReceipt = true;
|
receiptMessage = JsonReceiptMessage.deliveryReceipt(timestamp, List.of(timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonMessageEnvelope(Signal.SyncMessageReceived messageReceived) {
|
public JsonMessageEnvelope(Signal.SyncMessageReceived messageReceived) {
|
||||||
|
|
|
@ -22,4 +22,15 @@ class JsonReceiptMessage {
|
||||||
}
|
}
|
||||||
this.timestamps = receiptMessage.getTimestamps();
|
this.timestamps = receiptMessage.getTimestamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JsonReceiptMessage(final long when, final boolean isDelivery, final boolean isRead, final List<Long> timestamps) {
|
||||||
|
this.when = when;
|
||||||
|
this.isDelivery = isDelivery;
|
||||||
|
this.isRead = isRead;
|
||||||
|
this.timestamps = timestamps;
|
||||||
|
}
|
||||||
|
|
||||||
|
static JsonReceiptMessage deliveryReceipt(final long when, final List<Long> timestamps) {
|
||||||
|
return new JsonReceiptMessage(when, true, false, timestamps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue