import org.asamk.Signal;
import org.asamk.signal.manager.Manager;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
-import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
-import org.whispersystems.signalservice.api.messages.SignalServiceGroupContext;
-import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
import java.util.List;
import java.util.stream.Collectors;
@JsonInclude(JsonInclude.Include.NON_NULL)
final JsonSticker sticker;
+ @JsonProperty
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ final JsonRemoteDelete remoteDelete;
+
+ @JsonProperty
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ final List<JsonSharedContact> contacts;
+
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final JsonGroupInfo groupInfo;
JsonDataMessage(SignalServiceDataMessage dataMessage, Manager m) {
this.timestamp = dataMessage.getTimestamp();
if (dataMessage.getGroupContext().isPresent()) {
- final SignalServiceGroupContext groupContext = dataMessage.getGroupContext().get();
+ final var groupContext = dataMessage.getGroupContext().get();
if (groupContext.getGroupV1().isPresent()) {
- SignalServiceGroup groupInfo = groupContext.getGroupV1().get();
+ var groupInfo = groupContext.getGroupV1().get();
this.groupInfo = new JsonGroupInfo(groupInfo);
} else if (groupContext.getGroupV2().isPresent()) {
- SignalServiceGroupV2 groupInfo = groupContext.getGroupV2().get();
+ var groupInfo = groupContext.getGroupV2().get();
this.groupInfo = new JsonGroupInfo(groupInfo);
} else {
this.groupInfo = null;
} else {
this.mentions = List.of();
}
+ remoteDelete = dataMessage.getRemoteDelete().isPresent() ? new JsonRemoteDelete(dataMessage.getRemoteDelete()
+ .get()) : null;
if (dataMessage.getAttachments().isPresent()) {
this.attachments = dataMessage.getAttachments()
.get()
this.attachments = List.of();
}
this.sticker = dataMessage.getSticker().isPresent() ? new JsonSticker(dataMessage.getSticker().get()) : null;
+
+ if (dataMessage.getSharedContacts().isPresent()) {
+ this.contacts = dataMessage.getSharedContacts()
+ .get()
+ .stream()
+ .map(JsonSharedContact::new)
+ .collect(Collectors.toList());
+ } else {
+ this.contacts = List.of();
+ }
}
public JsonDataMessage(Signal.MessageReceived messageReceived) {
groupInfo = messageReceived.getGroupId().length > 0 ? new JsonGroupInfo(messageReceived.getGroupId()) : null;
expiresInSeconds = null;
viewOnce = null;
- reaction = null; // TODO Replace these 4 with the proper commands
+ remoteDelete = null;
+ reaction = null; // TODO Replace these 5 with the proper commands
quote = null;
mentions = null;
sticker = null;
+ contacts = null;
attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());
}
groupInfo = messageReceived.getGroupId().length > 0 ? new JsonGroupInfo(messageReceived.getGroupId()) : null;
expiresInSeconds = null;
viewOnce = null;
- reaction = null; // TODO Replace these 4 with the proper commands
+ remoteDelete = null;
+ reaction = null; // TODO Replace these 5 with the proper commands
quote = null;
mentions = null;
sticker = null;
+ contacts = null;
attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());
}
}