]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/ReceiveMessageHandler.java
Print additional call message content
[signal-cli] / src / main / java / org / asamk / signal / ReceiveMessageHandler.java
index 6ce21acd4c0c5f76f5ec3cade5156b5898b4e4aa..07dbfd1dfc14ce2d90955cdbe241d31d1b721c8e 100644 (file)
@@ -3,7 +3,6 @@ package org.asamk.signal;
 import org.asamk.signal.manager.Manager;
 import org.asamk.signal.manager.groups.GroupId;
 import org.asamk.signal.manager.groups.GroupUtils;
-import org.asamk.signal.manager.storage.contacts.ContactInfo;
 import org.asamk.signal.manager.storage.groups.GroupInfo;
 import org.asamk.signal.util.DateUtils;
 import org.asamk.signal.util.Util;
@@ -22,6 +21,7 @@ import org.whispersystems.signalservice.api.messages.calls.BusyMessage;
 import org.whispersystems.signalservice.api.messages.calls.HangupMessage;
 import org.whispersystems.signalservice.api.messages.calls.IceUpdateMessage;
 import org.whispersystems.signalservice.api.messages.calls.OfferMessage;
+import org.whispersystems.signalservice.api.messages.calls.OpaqueMessage;
 import org.whispersystems.signalservice.api.messages.calls.SignalServiceCallMessage;
 import org.whispersystems.signalservice.api.messages.multidevice.BlockedListMessage;
 import org.whispersystems.signalservice.api.messages.multidevice.ConfigurationMessage;
@@ -53,9 +53,9 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
     public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
         if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
             SignalServiceAddress source = envelope.getSourceAddress();
-            ContactInfo sourceContact = m.getContact(source.getLegacyIdentifier());
+            String name = m.getContactOrProfileName(source.getLegacyIdentifier());
             System.out.println(String.format("Envelope from: %s (device: %d)",
-                    (sourceContact == null ? "" : "“" + sourceContact.name + "” ") + source.getLegacyIdentifier(),
+                    (name == null ? "" : "“" + name + "” ") + source.getLegacyIdentifier(),
                     envelope.getSourceDevice()));
             if (source.getRelay().isPresent()) {
                 System.out.println("Relayed by: " + source.getRelay().get());
@@ -98,10 +98,9 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
             if (content == null) {
                 System.out.println("Failed to decrypt message.");
             } else {
-                ContactInfo sourceContact = m.getContact(content.getSender().getLegacyIdentifier());
+                String senderName = m.getContactOrProfileName(content.getSender().getLegacyIdentifier());
                 System.out.println(String.format("Sender: %s (device: %d)",
-                        (sourceContact == null ? "" : "“" + sourceContact.name + "” ") + content.getSender()
-                                .getLegacyIdentifier(),
+                        (senderName == null ? "" : "“" + senderName + "” ") + content.getSender().getLegacyIdentifier(),
                         content.getSenderDevice()));
                 if (content.getDataMessage().isPresent()) {
                     SignalServiceDataMessage message = content.getDataMessage().get();
@@ -127,10 +126,11 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
                     if (syncMessage.getRead().isPresent()) {
                         System.out.println("Received sync read messages list");
                         for (ReadMessage rm : syncMessage.getRead().get()) {
-                            ContactInfo fromContact = m.getContact(rm.getSender().getLegacyIdentifier());
+                            String name = m.getContactOrProfileName(rm.getSender().getLegacyIdentifier());
                             System.out.println("From: "
-                                    + (fromContact == null ? "" : "“" + fromContact.name + "” ")
-                                    + rm.getSender().getLegacyIdentifier()
+                                    + (name == null ? "" : "“" + name + "” ")
+                                    + rm.getSender()
+                                    .getLegacyIdentifier()
                                     + " Message timestamp: "
                                     + DateUtils.formatTimestamp(rm.getTimestamp()));
                         }
@@ -159,13 +159,13 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
                         String to;
                         if (sentTranscriptMessage.getDestination().isPresent()) {
                             String dest = sentTranscriptMessage.getDestination().get().getLegacyIdentifier();
-                            ContactInfo destContact = m.getContact(dest);
-                            to = (destContact == null ? "" : "“" + destContact.name + "” ") + dest;
+                            String name = m.getContactOrProfileName(dest);
+                            to = (name == null ? "" : "“" + name + "” ") + dest;
                         } else if (sentTranscriptMessage.getRecipients().size() > 0) {
                             StringBuilder toBuilder = new StringBuilder();
                             for (SignalServiceAddress dest : sentTranscriptMessage.getRecipients()) {
-                                ContactInfo destContact = m.getContact(dest.getLegacyIdentifier());
-                                toBuilder.append(destContact == null ? "" : "“" + destContact.name + "” ")
+                                String name = m.getContactOrProfileName(dest.getLegacyIdentifier());
+                                toBuilder.append(name == null ? "" : "“" + name + "” ")
                                         .append(dest.getLegacyIdentifier())
                                         .append(" ");
                             }
@@ -283,6 +283,10 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
                 if (content.getCallMessage().isPresent()) {
                     System.out.println("Received a call message");
                     SignalServiceCallMessage callMessage = content.getCallMessage().get();
+                    if (callMessage.getDestinationDeviceId().isPresent()) {
+                        final Integer deviceId = callMessage.getDestinationDeviceId().get();
+                        System.out.println("Destination device id: " + deviceId);
+                    }
                     if (callMessage.getAnswerMessage().isPresent()) {
                         AnswerMessage answerMessage = callMessage.getAnswerMessage().get();
                         System.out.println("Answer message: " + answerMessage.getId() + ": " + answerMessage.getSdp());
@@ -308,6 +312,10 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
                         OfferMessage offerMessage = callMessage.getOfferMessage().get();
                         System.out.println("Offer message: " + offerMessage.getId() + ": " + offerMessage.getSdp());
                     }
+                    if (callMessage.getOpaqueMessage().isPresent()) {
+                        final OpaqueMessage opaqueMessage = callMessage.getOpaqueMessage().get();
+                        System.out.println("Opaque message: size " + opaqueMessage.getOpaque().length);
+                    }
                 }
                 if (content.getReceiptMessage().isPresent()) {
                     System.out.println("Received a receipt message");
@@ -319,6 +327,9 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
                     if (receiptMessage.isReadReceipt()) {
                         System.out.println(" - Is read receipt");
                     }
+                    if (receiptMessage.isViewedReceipt()) {
+                        System.out.println(" - Is viewed receipt");
+                    }
                     System.out.println(" - Timestamps:");
                     for (long timestamp : receiptMessage.getTimestamps()) {
                         System.out.println("    " + DateUtils.formatTimestamp(timestamp));
@@ -398,6 +409,11 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
                 System.out.println("  Has signed group change: " + groupInfo.hasSignedGroupChange());
             }
         }
+        if (message.getGroupCallUpdate().isPresent()) {
+            final SignalServiceDataMessage.GroupCallUpdate groupCallUpdate = message.getGroupCallUpdate().get();
+            System.out.println("Group call update:");
+            System.out.println(" - Era id: " + groupCallUpdate.getEraId());
+        }
         if (message.getPreviews().isPresent()) {
             final List<SignalServiceDataMessage.Preview> previews = message.getPreviews().get();
             System.out.println("Previews:");