diff --git a/src/main/java/org/asamk/signal/JsonMessageEnvelope.java b/src/main/java/org/asamk/signal/JsonMessageEnvelope.java index e7003130..9484ce2e 100644 --- a/src/main/java/org/asamk/signal/JsonMessageEnvelope.java +++ b/src/main/java/org/asamk/signal/JsonMessageEnvelope.java @@ -19,6 +19,9 @@ class JsonMessageEnvelope { public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent content) { SignalServiceAddress source = envelope.getSourceAddress(); this.source = source.getNumber(); + if (this.source.equals("")) { + this.source = content.getSender(); + } this.sourceDevice = envelope.getSourceDevice(); this.relay = source.getRelay().isPresent() ? source.getRelay().get() : null; this.timestamp = envelope.getTimestamp(); diff --git a/src/main/java/org/asamk/signal/ReceiveMessageHandler.java b/src/main/java/org/asamk/signal/ReceiveMessageHandler.java index eeac7cb5..71f00baa 100644 --- a/src/main/java/org/asamk/signal/ReceiveMessageHandler.java +++ b/src/main/java/org/asamk/signal/ReceiveMessageHandler.java @@ -43,8 +43,12 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler { @Override public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) { SignalServiceAddress source = envelope.getSourceAddress(); - ContactInfo sourceContact = m.getContact(source.getNumber()); - System.out.println(String.format("Envelope from: %s (device: %d)", (sourceContact == null ? "" : "“" + sourceContact.name + "” ") + source.getNumber(), envelope.getSourceDevice())); + String sender = source.getNumber(); + if (sender.equals("")) { + sender = content.getSender(); + } + ContactInfo sourceContact = m.getContact(sender); + System.out.println(String.format("Envelope from: %s (device: %d)", (sourceContact == null ? "" : "“" + sourceContact.name + "” ") + sender, envelope.getSourceDevice())); if (source.getRelay().isPresent()) { System.out.println("Relayed by: " + source.getRelay().get()); }