Update libsignal-service-java

This commit is contained in:
AsamK 2021-08-26 21:23:30 +02:00
parent 85c5caeaca
commit 8bcd8d87d2
52 changed files with 692 additions and 551 deletions

View file

@ -4,9 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.asamk.signal.manager.Manager;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import java.util.UUID;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
@ -29,10 +26,10 @@ public class JsonMention {
final int length;
JsonMention(SignalServiceDataMessage.Mention mention, Manager m) {
final var address = m.resolveSignalServiceAddress(new SignalServiceAddress(mention.getUuid(), null));
final var address = m.resolveSignalServiceAddress(mention.getUuid());
this.name = getLegacyIdentifier(address);
this.number = address.getNumber().orNull();
this.uuid = address.getUuid().transform(UUID::toString).orNull();
this.uuid = address.getUuid().toString();
this.start = mention.getStart();
this.length = mention.getLength();
}

View file

@ -5,14 +5,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.asamk.Signal;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.UntrustedIdentityException;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.signal.libsignal.metadata.ProtocolUntrustedIdentityException;
import org.whispersystems.signalservice.api.messages.SignalServiceContent;
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import java.util.List;
import java.util.UUID;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
@ -34,10 +33,6 @@ public class JsonMessageEnvelope {
@JsonProperty
final Integer sourceDevice;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final String relay;
@JsonProperty
final long timestamp;
@ -64,34 +59,30 @@ public class JsonMessageEnvelope {
public JsonMessageEnvelope(
SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception, Manager m
) {
if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
var source = envelope.getSourceAddress();
if (!envelope.isUnidentifiedSender() && envelope.hasSourceUuid()) {
var source = m.resolveSignalServiceAddress(envelope.getSourceAddress());
this.source = getLegacyIdentifier(source);
this.sourceNumber = source.getNumber().orNull();
this.sourceUuid = source.getUuid().transform(UUID::toString).orNull();
this.sourceUuid = source.getUuid().toString();
this.sourceDevice = envelope.getSourceDevice();
this.relay = source.getRelay().orNull();
} else if (envelope.isUnidentifiedSender() && content != null) {
final var source = content.getSender();
final var source = m.resolveSignalServiceAddress(content.getSender());
this.source = getLegacyIdentifier(source);
this.sourceNumber = source.getNumber().orNull();
this.sourceUuid = source.getUuid().transform(UUID::toString).orNull();
this.sourceUuid = source.getUuid().toString();
this.sourceDevice = content.getSenderDevice();
this.relay = null;
} else if (exception instanceof ProtocolUntrustedIdentityException) {
var e = (ProtocolUntrustedIdentityException) exception;
} else if (exception instanceof UntrustedIdentityException) {
var e = (UntrustedIdentityException) exception;
final var source = m.resolveSignalServiceAddress(e.getSender());
this.source = getLegacyIdentifier(source);
this.sourceNumber = source.getNumber().orNull();
this.sourceUuid = source.getUuid().transform(UUID::toString).orNull();
this.sourceUuid = source.getUuid().toString();
this.sourceDevice = e.getSenderDevice();
this.relay = null;
} else {
this.source = null;
this.sourceNumber = null;
this.sourceUuid = null;
this.sourceDevice = null;
this.relay = null;
}
String name;
try {
@ -129,7 +120,6 @@ public class JsonMessageEnvelope {
sourceUuid = null;
sourceName = null;
sourceDevice = null;
relay = null;
timestamp = messageReceived.getTimestamp();
receiptMessage = null;
dataMessage = new JsonDataMessage(messageReceived);
@ -144,7 +134,6 @@ public class JsonMessageEnvelope {
sourceUuid = null;
sourceName = null;
sourceDevice = null;
relay = null;
timestamp = receiptReceived.getTimestamp();
receiptMessage = JsonReceiptMessage.deliveryReceipt(timestamp, List.of(timestamp));
dataMessage = null;
@ -159,7 +148,6 @@ public class JsonMessageEnvelope {
sourceUuid = null;
sourceName = null;
sourceDevice = null;
relay = null;
timestamp = messageReceived.getTimestamp();
receiptMessage = null;
dataMessage = null;

View file

@ -8,7 +8,6 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
@ -43,7 +42,7 @@ public class JsonQuote {
final var address = m.resolveSignalServiceAddress(quote.getAuthor());
this.author = getLegacyIdentifier(address);
this.authorNumber = address.getNumber().orNull();
this.authorUuid = address.getUuid().transform(UUID::toString).orNull();
this.authorUuid = address.getUuid().toString();
this.text = quote.getText();
if (quote.getMentions() != null && quote.getMentions().size() > 0) {

View file

@ -5,8 +5,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.asamk.signal.manager.Manager;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Reaction;
import java.util.UUID;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
public class JsonReaction {
@ -35,7 +33,7 @@ public class JsonReaction {
final var address = m.resolveSignalServiceAddress(reaction.getTargetAuthor());
this.targetAuthor = getLegacyIdentifier(address);
this.targetAuthorNumber = address.getNumber().orNull();
this.targetAuthorUuid = address.getUuid().transform(UUID::toString).orNull();
this.targetAuthorUuid = address.getUuid().toString();
this.targetSentTimestamp = reaction.getTargetSentTimestamp();
this.isRemove = reaction.isRemove();
}

View file

@ -6,8 +6,6 @@ import org.asamk.Signal;
import org.asamk.signal.manager.Manager;
import org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptMessage;
import java.util.UUID;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
class JsonSyncDataMessage extends JsonDataMessage {
@ -29,7 +27,7 @@ class JsonSyncDataMessage extends JsonDataMessage {
final var address = transcriptMessage.getDestination().get();
this.destination = getLegacyIdentifier(address);
this.destinationNumber = address.getNumber().orNull();
this.destinationUuid = address.getUuid().transform(UUID::toString).orNull();
this.destinationUuid = address.getUuid().toString();
} else {
this.destination = null;
this.destinationNumber = null;

View file

@ -4,8 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.whispersystems.signalservice.api.messages.multidevice.ReadMessage;
import java.util.UUID;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
class JsonSyncReadMessage {
@ -27,7 +25,7 @@ class JsonSyncReadMessage {
final var sender = readMessage.getSender();
this.sender = getLegacyIdentifier(sender);
this.senderNumber = sender.getNumber().orNull();
this.senderUuid = sender.getUuid().transform(UUID::toString).orNull();
this.senderUuid = sender.getUuid().toString();
this.timestamp = readMessage.getTimestamp();
}
}