mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 11:00:38 +00:00
Implement json output for receive
This commit is contained in:
parent
a1f0d74a99
commit
8717665d1d
9 changed files with 225 additions and 2 deletions
36
src/main/java/org/asamk/signal/JsonMessageEnvelope.java
Normal file
36
src/main/java/org/asamk/signal/JsonMessageEnvelope.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package org.asamk.signal;
|
||||
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
class JsonMessageEnvelope {
|
||||
String source;
|
||||
int sourceDevice;
|
||||
String relay;
|
||||
long timestamp;
|
||||
boolean isReceipt;
|
||||
JsonDataMessage dataMessage;
|
||||
JsonSyncMessage syncMessage;
|
||||
JsonCallMessage callMessage;
|
||||
|
||||
public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent content) {
|
||||
SignalServiceAddress source = envelope.getSourceAddress();
|
||||
this.source = source.getNumber();
|
||||
this.sourceDevice = envelope.getSourceDevice();
|
||||
this.relay = source.getRelay().isPresent() ? source.getRelay().get() : null;
|
||||
this.timestamp = envelope.getTimestamp();
|
||||
this.isReceipt = envelope.isReceipt();
|
||||
if (content != null) {
|
||||
if (content.getDataMessage().isPresent()) {
|
||||
this.dataMessage = new JsonDataMessage(content.getDataMessage().get());
|
||||
}
|
||||
if (content.getSyncMessage().isPresent()) {
|
||||
this.syncMessage = new JsonSyncMessage(content.getSyncMessage().get());
|
||||
}
|
||||
if (content.getCallMessage().isPresent()) {
|
||||
this.callMessage = new JsonCallMessage(content.getCallMessage().get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue