mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-01 20:10:39 +00:00
FIX: NullpointerException for messages without content in mqttHandler
This commit is contained in:
parent
055a8a421f
commit
92879048a1
2 changed files with 29 additions and 16 deletions
|
@ -80,7 +80,7 @@ public class MqttJsonMessage {
|
|||
|
||||
if (envelope != null) {
|
||||
result.putPOJO("envelope", new JsonMessageEnvelope(envelope, content));
|
||||
message.setSubTopic(findSubTopic(content));
|
||||
message.setSubTopic(findSubTopic(envelope, content));
|
||||
}
|
||||
try {
|
||||
message.setContent(jsonProcessor.writeValueAsString(result));
|
||||
|
@ -102,22 +102,37 @@ public class MqttJsonMessage {
|
|||
* Finds the designated type of the message and defines the subtopic for the mqtt broker.
|
||||
*
|
||||
* Possible subtopics: data, synq, call, typinginfo, receipt, other
|
||||
*
|
||||
* @param envelope
|
||||
* @param content
|
||||
* @return
|
||||
*/
|
||||
private static String findSubTopic(final SignalServiceContent content) {
|
||||
if (content.getDataMessage().isPresent()) {
|
||||
return SUBTOPIC_DATA;
|
||||
} else if (content.getSyncMessage().isPresent()) {
|
||||
return SUBTOPIC_SYNC;
|
||||
} else if (content.getCallMessage().isPresent()) {
|
||||
return SUBTOPIC_CALL;
|
||||
} else if (content.getTypingMessage().isPresent()) {
|
||||
return SUBTOPIC_TYPING_INFO;
|
||||
} else if (content.getReceiptMessage().isPresent()) {
|
||||
return SUBTOPIC_RECEIPT;
|
||||
} else {
|
||||
return SUBTOPIC_OTHER;
|
||||
private static String findSubTopic(final SignalServiceEnvelope envelope, final SignalServiceContent content) {
|
||||
if(content !=null) {
|
||||
if (content.getDataMessage().isPresent()) {
|
||||
return SUBTOPIC_DATA;
|
||||
} else if (content.getSyncMessage().isPresent()) {
|
||||
return SUBTOPIC_SYNC;
|
||||
} else if (content.getCallMessage().isPresent()) {
|
||||
return SUBTOPIC_CALL;
|
||||
} else if (content.getTypingMessage().isPresent()) {
|
||||
return SUBTOPIC_TYPING_INFO;
|
||||
} else if (content.getReceiptMessage().isPresent()) {
|
||||
return SUBTOPIC_RECEIPT;
|
||||
} else {
|
||||
return SUBTOPIC_OTHER;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(envelope.isReceipt())
|
||||
{
|
||||
return SUBTOPIC_RECEIPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SUBTOPIC_OTHER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,6 @@ public class MqttReceiveMessageHandler implements Manager.ReceiveMessageHandler
|
|||
|
||||
@Override
|
||||
public void handleMessage(final SignalServiceEnvelope envelope, final SignalServiceContent decryptedContent, final Throwable e) {
|
||||
System.out.println("Message Received from " + decryptedContent.getSender());
|
||||
|
||||
MqttJsonMessage msg = MqttJsonMessage.build(envelope, decryptedContent, e);
|
||||
String topic = DEFAULT_TOPIC + stripIllegalTopicCharacters(manager.getUsername() + "/" + msg.getSubTopic());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue