Output json when receiving messages from dbus and --json parameter is given

Fixes #138
This commit is contained in:
AsamK 2020-04-03 16:22:10 +02:00
parent e04c45766d
commit ae41d0c502
15 changed files with 176 additions and 50 deletions

View file

@ -9,9 +9,9 @@ import org.whispersystems.signalservice.api.messages.SignalServiceContent;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
import org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptMessage;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
import java.util.ArrayList;
import java.util.List;
@ -40,12 +40,25 @@ public class JsonDbusReceiveMessageHandler extends JsonReceiveMessageHandler {
e.printStackTrace();
}
} else if (content != null) {
if (content.getDataMessage().isPresent()) {
if (content.getReceiptMessage().isPresent()) {
final SignalServiceReceiptMessage receiptMessage = content.getReceiptMessage().get();
if (receiptMessage.isDeliveryReceipt()) {
final String sender = !envelope.isUnidentifiedSender() && envelope.hasSource() ? envelope.getSourceE164().get() : content.getSender().getNumber().get();
for (long timestamp : receiptMessage.getTimestamps()) {
try {
conn.sendSignal(new Signal.ReceiptReceived(
objectPath,
timestamp,
sender
));
} catch (DBusException e) {
e.printStackTrace();
}
}
}
} else if (content.getDataMessage().isPresent()) {
SignalServiceDataMessage message = content.getDataMessage().get();
if (message.getBody().isPresent())
System.out.println(message.getBody().get());
if (!message.isEndSession() &&
!(message.getGroupContext().isPresent() &&
message.getGroupContext().get().getGroupV1Type() != SignalServiceGroup.Type.DELIVER)) {