Update libsignal-service-java

This commit is contained in:
AsamK 2021-05-19 22:51:35 +02:00
parent f445cfb5c1
commit 30690785fd
19 changed files with 71 additions and 42 deletions

View file

@ -4,9 +4,9 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.asamk.signal.manager.groups.GroupUtils;
import org.asamk.signal.util.Util;
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import java.util.Base64;
import java.util.List;
@ -36,7 +36,7 @@ class JsonGroupInfo {
this.members = groupInfo.getMembers()
.get()
.stream()
.map(SignalServiceAddress::getLegacyIdentifier)
.map(Util::getLegacyIdentifier)
.collect(Collectors.toList());
} else {
this.members = null;

View file

@ -6,6 +6,8 @@ import org.asamk.signal.manager.Manager;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
public class JsonMention {
@JsonProperty
@ -18,8 +20,8 @@ public class JsonMention {
final int length;
JsonMention(SignalServiceDataMessage.Mention mention, Manager m) {
this.name = m.resolveSignalServiceAddress(new SignalServiceAddress(mention.getUuid(), null))
.getLegacyIdentifier();
this.name = getLegacyIdentifier(m.resolveSignalServiceAddress(new SignalServiceAddress(mention.getUuid(),
null)));
this.start = mention.getStart();
this.length = mention.getLength();
}

View file

@ -10,6 +10,8 @@ import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
import java.util.List;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
public class JsonMessageEnvelope {
@JsonProperty
@ -48,11 +50,11 @@ public class JsonMessageEnvelope {
public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent content, Manager m) {
if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
var source = envelope.getSourceAddress();
this.source = source.getLegacyIdentifier();
this.source = getLegacyIdentifier(source);
this.sourceDevice = envelope.getSourceDevice();
this.relay = source.getRelay().orNull();
} else if (envelope.isUnidentifiedSender() && content != null) {
this.source = content.getSender().getLegacyIdentifier();
this.source = getLegacyIdentifier(content.getSender());
this.sourceDevice = content.getSenderDevice();
this.relay = null;
} else {

View file

@ -10,6 +10,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
public class JsonQuote {
@JsonProperty
@ -30,7 +32,7 @@ public class JsonQuote {
JsonQuote(SignalServiceDataMessage.Quote quote, Manager m) {
this.id = quote.getId();
this.author = m.resolveSignalServiceAddress(quote.getAuthor()).getLegacyIdentifier();
this.author = getLegacyIdentifier(m.resolveSignalServiceAddress(quote.getAuthor()));
this.text = quote.getText();
if (quote.getMentions() != null && quote.getMentions().size() > 0) {

View file

@ -5,6 +5,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.asamk.signal.manager.Manager;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Reaction;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
public class JsonReaction {
@JsonProperty
@ -21,7 +23,7 @@ public class JsonReaction {
JsonReaction(Reaction reaction, Manager m) {
this.emoji = reaction.getEmoji();
this.targetAuthor = m.resolveSignalServiceAddress(reaction.getTargetAuthor()).getLegacyIdentifier();
this.targetAuthor = getLegacyIdentifier(m.resolveSignalServiceAddress(reaction.getTargetAuthor()));
this.targetSentTimestamp = reaction.getTargetSentTimestamp();
this.isRemove = reaction.isRemove();
}

View file

@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.asamk.Signal;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.util.Util;
import org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptMessage;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
class JsonSyncDataMessage extends JsonDataMessage {
@ -15,9 +15,7 @@ class JsonSyncDataMessage extends JsonDataMessage {
JsonSyncDataMessage(SentTranscriptMessage transcriptMessage, Manager m) {
super(transcriptMessage.getMessage(), m);
this.destination = transcriptMessage.getDestination()
.transform(SignalServiceAddress::getLegacyIdentifier)
.orNull();
this.destination = transcriptMessage.getDestination().transform(Util::getLegacyIdentifier).orNull();
}
JsonSyncDataMessage(Signal.SyncMessageReceived messageReceived) {

View file

@ -5,13 +5,15 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.asamk.Signal;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.util.Util;
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import java.util.Base64;
import java.util.List;
import java.util.stream.Collectors;
import static org.asamk.signal.util.Util.getLegacyIdentifier;
enum JsonSyncMessageType {
CONTACTS_SYNC,
GROUPS_SYNC,
@ -50,7 +52,7 @@ class JsonSyncMessage {
.get()
.getAddresses()
.stream()
.map(SignalServiceAddress::getLegacyIdentifier)
.map(Util::getLegacyIdentifier)
.collect(Collectors.toList());
this.blockedGroupIds = syncMessage.getBlockedList()
.get()
@ -66,7 +68,7 @@ class JsonSyncMessage {
this.readMessages = syncMessage.getRead()
.get()
.stream()
.map(message -> new JsonSyncReadMessage(message.getSender().getLegacyIdentifier(),
.map(message -> new JsonSyncReadMessage(getLegacyIdentifier(message.getSender()),
message.getTimestamp()))
.collect(Collectors.toList());
} else {