From 209c613e4377c0d9e7a6db4e428a8df0af82745b Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Mon, 11 Nov 2019 04:34:04 +0100 Subject: [PATCH] Add basic sealed sender support --- src/main/java/org/asamk/signal/JsonMessageEnvelope.java | 3 +++ src/main/java/org/asamk/signal/ReceiveMessageHandler.java | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) 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()); }