mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Output json when receiving messages from dbus and --json parameter is given
Fixes #138
This commit is contained in:
parent
e04c45766d
commit
ae41d0c502
15 changed files with 176 additions and 50 deletions
|
@ -1,37 +0,0 @@
|
|||
package org.asamk.signal;
|
||||
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
||||
|
||||
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.getGroupContext().isPresent() && dataMessage.getGroupContext().get().getGroupV1().isPresent()) {
|
||||
SignalServiceGroup groupInfo = dataMessage.getGroupContext().get().getGroupV1().get();
|
||||
this.groupInfo = new JsonGroupInfo(groupInfo);
|
||||
}
|
||||
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