mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Quotes, Mentions and Reactions in non-daemon JSON mode (#389)
* Added support for quotes, mentions and reactions in non-daemon JSON output
This commit is contained in:
parent
548c313b4c
commit
58db3cbd53
10 changed files with 162 additions and 19 deletions
|
@ -1,6 +1,7 @@
|
|||
package org.asamk.signal.json;
|
||||
|
||||
import org.asamk.Signal;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
||||
|
@ -15,10 +16,14 @@ class JsonDataMessage {
|
|||
long timestamp;
|
||||
String message;
|
||||
int expiresInSeconds;
|
||||
|
||||
JsonReaction reaction;
|
||||
JsonQuote quote;
|
||||
List<JsonMention> mentions;
|
||||
List<JsonAttachment> attachments;
|
||||
JsonGroupInfo groupInfo;
|
||||
|
||||
JsonDataMessage(SignalServiceDataMessage dataMessage) {
|
||||
JsonDataMessage(SignalServiceDataMessage dataMessage, Manager m) {
|
||||
this.timestamp = dataMessage.getTimestamp();
|
||||
if (dataMessage.getGroupContext().isPresent()) {
|
||||
if (dataMessage.getGroupContext().get().getGroupV1().isPresent()) {
|
||||
|
@ -33,6 +38,20 @@ class JsonDataMessage {
|
|||
this.message = dataMessage.getBody().get();
|
||||
}
|
||||
this.expiresInSeconds = dataMessage.getExpiresInSeconds();
|
||||
if (dataMessage.getReaction().isPresent()) {
|
||||
this.reaction = new JsonReaction(dataMessage.getReaction().get(), m);
|
||||
}
|
||||
if (dataMessage.getQuote().isPresent()) {
|
||||
this.quote = new JsonQuote(dataMessage.getQuote().get(), m);
|
||||
}
|
||||
if (dataMessage.getMentions().isPresent()) {
|
||||
this.mentions = new ArrayList<>(dataMessage.getMentions().get().size());
|
||||
for (SignalServiceDataMessage.Mention mention : dataMessage.getMentions().get()) {
|
||||
this.mentions.add(new JsonMention(mention, m));
|
||||
}
|
||||
} else {
|
||||
this.mentions = new ArrayList<>();
|
||||
}
|
||||
if (dataMessage.getAttachments().isPresent()) {
|
||||
this.attachments = new ArrayList<>(dataMessage.getAttachments().get().size());
|
||||
for (SignalServiceAttachment attachment : dataMessage.getAttachments().get()) {
|
||||
|
@ -47,6 +66,9 @@ class JsonDataMessage {
|
|||
timestamp = messageReceived.getTimestamp();
|
||||
message = messageReceived.getMessage();
|
||||
groupInfo = new JsonGroupInfo(messageReceived.getGroupId());
|
||||
reaction = null; // TODO Replace these 3 with the proper commands
|
||||
quote = null;
|
||||
mentions = null;
|
||||
attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -54,6 +76,9 @@ class JsonDataMessage {
|
|||
timestamp = messageReceived.getTimestamp();
|
||||
message = messageReceived.getMessage();
|
||||
groupInfo = new JsonGroupInfo(messageReceived.getGroupId());
|
||||
reaction = null; // TODO Replace these 3 with the proper commands
|
||||
quote = null;
|
||||
mentions = null;
|
||||
attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue