mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
parent
5a2c4b8dfd
commit
3b29add396
2 changed files with 38 additions and 0 deletions
|
@ -41,6 +41,10 @@ public class JsonMessageEnvelope {
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
final JsonReceiptMessage receiptMessage;
|
final JsonReceiptMessage receiptMessage;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
final JsonTypingMessage typingMessage;
|
||||||
|
|
||||||
public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent content, Manager m) {
|
public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent content, Manager m) {
|
||||||
if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
|
if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
|
||||||
SignalServiceAddress source = envelope.getSourceAddress();
|
SignalServiceAddress source = envelope.getSourceAddress();
|
||||||
|
@ -64,6 +68,9 @@ public class JsonMessageEnvelope {
|
||||||
} else {
|
} else {
|
||||||
this.receiptMessage = null;
|
this.receiptMessage = null;
|
||||||
}
|
}
|
||||||
|
this.typingMessage = content != null && content.getTypingMessage().isPresent()
|
||||||
|
? new JsonTypingMessage(content.getTypingMessage().get())
|
||||||
|
: null;
|
||||||
|
|
||||||
this.dataMessage = content != null && content.getDataMessage().isPresent()
|
this.dataMessage = content != null && content.getDataMessage().isPresent()
|
||||||
? new JsonDataMessage(content.getDataMessage().get(), m)
|
? new JsonDataMessage(content.getDataMessage().get(), m)
|
||||||
|
@ -85,6 +92,7 @@ public class JsonMessageEnvelope {
|
||||||
dataMessage = new JsonDataMessage(messageReceived);
|
dataMessage = new JsonDataMessage(messageReceived);
|
||||||
syncMessage = null;
|
syncMessage = null;
|
||||||
callMessage = null;
|
callMessage = null;
|
||||||
|
typingMessage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonMessageEnvelope(Signal.ReceiptReceived receiptReceived) {
|
public JsonMessageEnvelope(Signal.ReceiptReceived receiptReceived) {
|
||||||
|
@ -96,6 +104,7 @@ public class JsonMessageEnvelope {
|
||||||
dataMessage = null;
|
dataMessage = null;
|
||||||
syncMessage = null;
|
syncMessage = null;
|
||||||
callMessage = null;
|
callMessage = null;
|
||||||
|
typingMessage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonMessageEnvelope(Signal.SyncMessageReceived messageReceived) {
|
public JsonMessageEnvelope(Signal.SyncMessageReceived messageReceived) {
|
||||||
|
@ -107,5 +116,6 @@ public class JsonMessageEnvelope {
|
||||||
dataMessage = null;
|
dataMessage = null;
|
||||||
syncMessage = new JsonSyncMessage(messageReceived);
|
syncMessage = new JsonSyncMessage(messageReceived);
|
||||||
callMessage = null;
|
callMessage = null;
|
||||||
|
typingMessage = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
28
src/main/java/org/asamk/signal/json/JsonTypingMessage.java
Normal file
28
src/main/java/org/asamk/signal/json/JsonTypingMessage.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package org.asamk.signal.json;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
||||||
|
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
class JsonTypingMessage {
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
final String action;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
final long timestamp;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
final String groupId;
|
||||||
|
|
||||||
|
JsonTypingMessage(SignalServiceTypingMessage typingMessage) {
|
||||||
|
this.action = typingMessage.getAction().name();
|
||||||
|
this.timestamp = typingMessage.getTimestamp();
|
||||||
|
final Base64.Encoder encoder = Base64.getEncoder();
|
||||||
|
this.groupId = typingMessage.getGroupId().transform(encoder::encodeToString).orNull();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue