mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-04 13:10:39 +00:00
Use record classes
This commit is contained in:
parent
ce70a623c2
commit
ce7aa580b6
66 changed files with 754 additions and 1877 deletions
|
@ -1,6 +1,6 @@
|
|||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
|
||||
import org.asamk.Signal;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
|
@ -8,37 +8,30 @@ import org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptM
|
|||
|
||||
import static org.asamk.signal.util.Util.getLegacyIdentifier;
|
||||
|
||||
class JsonSyncDataMessage extends JsonDataMessage {
|
||||
|
||||
@JsonProperty
|
||||
@Deprecated
|
||||
final String destination;
|
||||
|
||||
@JsonProperty
|
||||
final String destinationNumber;
|
||||
|
||||
@JsonProperty
|
||||
final String destinationUuid;
|
||||
|
||||
JsonSyncDataMessage(SentTranscriptMessage transcriptMessage, Manager m) {
|
||||
super(transcriptMessage.getMessage(), m);
|
||||
record JsonSyncDataMessage(
|
||||
@Deprecated String destination,
|
||||
String destinationNumber,
|
||||
String destinationUuid,
|
||||
@JsonUnwrapped JsonDataMessage dataMessage
|
||||
) {
|
||||
|
||||
static JsonSyncDataMessage from(SentTranscriptMessage transcriptMessage, Manager m) {
|
||||
if (transcriptMessage.getDestination().isPresent()) {
|
||||
final var address = transcriptMessage.getDestination().get();
|
||||
this.destination = getLegacyIdentifier(address);
|
||||
this.destinationNumber = address.getNumber().orNull();
|
||||
this.destinationUuid = address.getUuid().toString();
|
||||
return new JsonSyncDataMessage(getLegacyIdentifier(address),
|
||||
address.getNumber().orNull(),
|
||||
address.getUuid().toString(),
|
||||
JsonDataMessage.from(transcriptMessage.getMessage(), m));
|
||||
|
||||
} else {
|
||||
this.destination = null;
|
||||
this.destinationNumber = null;
|
||||
this.destinationUuid = null;
|
||||
return new JsonSyncDataMessage(null, null, null, JsonDataMessage.from(transcriptMessage.getMessage(), m));
|
||||
}
|
||||
}
|
||||
|
||||
JsonSyncDataMessage(Signal.SyncMessageReceived messageReceived) {
|
||||
super(messageReceived);
|
||||
this.destination = messageReceived.getDestination();
|
||||
this.destinationNumber = null;
|
||||
this.destinationUuid = null;
|
||||
static JsonSyncDataMessage from(Signal.SyncMessageReceived messageReceived) {
|
||||
return new JsonSyncDataMessage(messageReceived.getDestination(),
|
||||
null,
|
||||
null,
|
||||
JsonDataMessage.from(messageReceived));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue