mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +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
34
src/main/java/org/asamk/signal/JsonDataMessage.java
Normal file
34
src/main/java/org/asamk/signal/JsonDataMessage.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package org.asamk.signal;
|
||||
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class JsonDataMessage {
|
||||
long timestamp;
|
||||
String message;
|
||||
int expiresInSeconds;
|
||||
List<JsonAttachment> attachments;
|
||||
JsonGroupInfo groupInfo;
|
||||
|
||||
JsonDataMessage(SignalServiceDataMessage dataMessage) {
|
||||
this.timestamp = dataMessage.getTimestamp();
|
||||
if (dataMessage.getGroupInfo().isPresent()) {
|
||||
this.groupInfo = new JsonGroupInfo(dataMessage.getGroupInfo().get());
|
||||
}
|
||||
if (dataMessage.getBody().isPresent()) {
|
||||
this.message = dataMessage.getBody().get();
|
||||
}
|
||||
this.expiresInSeconds = dataMessage.getExpiresInSeconds();
|
||||
if (dataMessage.getAttachments().isPresent()) {
|
||||
this.attachments = new ArrayList<>(dataMessage.getAttachments().get().size());
|
||||
for (SignalServiceAttachment attachment : dataMessage.getAttachments().get()) {
|
||||
this.attachments.add(new JsonAttachment(attachment));
|
||||
}
|
||||
} else {
|
||||
this.attachments = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue