mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
add group info on json message
This commit is contained in:
parent
5646f65195
commit
eac2a47163
5 changed files with 22 additions and 11 deletions
|
@ -2,6 +2,7 @@ package org.asamk.signal.json;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -25,10 +26,10 @@ record JsonDataMessage(
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL) JsonStoryContext storyContext
|
@JsonInclude(JsonInclude.Include.NON_NULL) JsonStoryContext storyContext
|
||||||
) {
|
) {
|
||||||
|
|
||||||
static JsonDataMessage from(MessageEnvelope.Data dataMessage) {
|
static JsonDataMessage from(MessageEnvelope.Data dataMessage, Manager m) {
|
||||||
final var timestamp = dataMessage.timestamp();
|
final var timestamp = dataMessage.timestamp();
|
||||||
final var groupInfo = dataMessage.groupContext().isPresent() ? JsonGroupInfo.from(dataMessage.groupContext()
|
final var groupInfo = dataMessage.groupContext().isPresent() ? JsonGroupInfo.from(dataMessage.groupContext()
|
||||||
.get()) : null;
|
.get(), m) : null;
|
||||||
final var storyContext = dataMessage.storyContext().isPresent()
|
final var storyContext = dataMessage.storyContext().isPresent()
|
||||||
? JsonStoryContext.from(dataMessage.storyContext().get())
|
? JsonStoryContext.from(dataMessage.storyContext().get())
|
||||||
: null;
|
: null;
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package org.asamk.signal.json;
|
package org.asamk.signal.json;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||||
|
|
||||||
record JsonEditMessage(long targetSentTimestamp, JsonDataMessage dataMessage) {
|
record JsonEditMessage(long targetSentTimestamp, JsonDataMessage dataMessage) {
|
||||||
|
|
||||||
static JsonEditMessage from(MessageEnvelope.Edit editMessage) {
|
static JsonEditMessage from(MessageEnvelope.Edit editMessage, Manager m) {
|
||||||
return new JsonEditMessage(editMessage.targetSentTimestamp(), JsonDataMessage.from(editMessage.dataMessage()));
|
return new JsonEditMessage(editMessage.targetSentTimestamp(), JsonDataMessage.from(editMessage.dataMessage(), m));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package org.asamk.signal.json;
|
package org.asamk.signal.json;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||||
|
|
||||||
record JsonGroupInfo(String groupId, String type) {
|
record JsonGroupInfo(String groupId, String groupName, int revision, String type) {
|
||||||
|
|
||||||
static JsonGroupInfo from(MessageEnvelope.Data.GroupContext groupContext) {
|
static JsonGroupInfo from(MessageEnvelope.Data.GroupContext groupContext, Manager m) {
|
||||||
return new JsonGroupInfo(groupContext.groupId().toBase64(),
|
return new JsonGroupInfo(groupContext.groupId().toBase64(),
|
||||||
|
m.getGroup(groupContext.groupId()).title(),
|
||||||
|
groupContext.revision(),
|
||||||
groupContext.isGroupUpdate() ? "UPDATE" : "DELIVER");
|
groupContext.isGroupUpdate() ? "UPDATE" : "DELIVER");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.asamk.signal.json;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||||
import org.asamk.signal.manager.api.RecipientAddress;
|
import org.asamk.signal.manager.api.RecipientAddress;
|
||||||
|
|
||||||
|
@ -16,13 +17,17 @@ record JsonSyncDataMessage(
|
||||||
@JsonUnwrapped JsonDataMessage dataMessage
|
@JsonUnwrapped JsonDataMessage dataMessage
|
||||||
) {
|
) {
|
||||||
|
|
||||||
static JsonSyncDataMessage from(MessageEnvelope.Sync.Sent transcriptMessage) {
|
static JsonSyncDataMessage from(MessageEnvelope.Sync.Sent transcriptMessage, Manager m) {
|
||||||
return new JsonSyncDataMessage(transcriptMessage.destination()
|
return new JsonSyncDataMessage(transcriptMessage.destination()
|
||||||
.map(RecipientAddress::getLegacyIdentifier)
|
.map(RecipientAddress::getLegacyIdentifier)
|
||||||
.orElse(null),
|
.orElse(null),
|
||||||
transcriptMessage.destination().flatMap(RecipientAddress::number).orElse(null),
|
transcriptMessage.destination().flatMap(RecipientAddress::number).orElse(null),
|
||||||
transcriptMessage.destination().flatMap(address -> address.uuid().map(UUID::toString)).orElse(null),
|
transcriptMessage.destination().flatMap(address -> address.uuid().map(UUID::toString)).orElse(null),
|
||||||
transcriptMessage.editMessage().map(JsonEditMessage::from).orElse(null),
|
transcriptMessage.editMessage()
|
||||||
transcriptMessage.message().map(JsonDataMessage::from).orElse(null));
|
.map(data -> JsonEditMessage.from(data, m))
|
||||||
|
.orElse(null),
|
||||||
|
transcriptMessage.message()
|
||||||
|
.map(data -> JsonDataMessage.from(data, m))
|
||||||
|
.orElse(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.asamk.signal.json;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.api.GroupId;
|
import org.asamk.signal.manager.api.GroupId;
|
||||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||||
import org.asamk.signal.manager.api.RecipientAddress;
|
import org.asamk.signal.manager.api.RecipientAddress;
|
||||||
|
@ -23,9 +24,9 @@ record JsonSyncMessage(
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL) JsonSyncMessageType type
|
@JsonInclude(JsonInclude.Include.NON_NULL) JsonSyncMessageType type
|
||||||
) {
|
) {
|
||||||
|
|
||||||
static JsonSyncMessage from(MessageEnvelope.Sync syncMessage) {
|
static JsonSyncMessage from(MessageEnvelope.Sync syncMessage, Manager m) {
|
||||||
final var sentMessage = syncMessage.sent().isPresent() && syncMessage.sent().get().story().isEmpty()
|
final var sentMessage = syncMessage.sent().isPresent() && syncMessage.sent().get().story().isEmpty()
|
||||||
? JsonSyncDataMessage.from(syncMessage.sent().get())
|
? JsonSyncDataMessage.from(syncMessage.sent().get(), m)
|
||||||
: null;
|
: null;
|
||||||
final var sentStoryMessage = syncMessage.sent().isPresent() && syncMessage.sent().get().story().isPresent()
|
final var sentStoryMessage = syncMessage.sent().isPresent() && syncMessage.sent().get().story().isPresent()
|
||||||
? JsonSyncStoryMessage.from(syncMessage.sent().get())
|
? JsonSyncStoryMessage.from(syncMessage.sent().get())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue