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

@ -1,12 +1,12 @@
package org.asamk.signal;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.UntrustedIdentityException;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.groups.GroupId;
import org.asamk.signal.manager.groups.GroupUtils;
import org.asamk.signal.util.DateUtils;
import org.asamk.signal.util.Util;
import org.signal.libsignal.metadata.ProtocolUntrustedIdentityException;
import org.slf4j.helpers.MessageFormatter;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
import org.whispersystems.signalservice.api.messages.SignalServiceContent;
@ -38,12 +38,9 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
@Override
public void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, Throwable exception) {
if (envelope.hasSource()) {
if (envelope.hasSourceUuid()) {
var source = envelope.getSourceAddress();
writer.println("Envelope from: {} (device: {})", formatContact(source), envelope.getSourceDevice());
if (source.getRelay().isPresent()) {
writer.println("Relayed by: {}", source.getRelay().get());
}
} else {
writer.println("Envelope from: unknown source");
}
@ -56,8 +53,8 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
writer.println("Got receipt.");
} else if (envelope.isSignalMessage() || envelope.isPreKeySignalMessage() || envelope.isUnidentifiedSender()) {
if (exception != null) {
if (exception instanceof ProtocolUntrustedIdentityException) {
var e = (ProtocolUntrustedIdentityException) exception;
if (exception instanceof UntrustedIdentityException) {
var e = (UntrustedIdentityException) exception;
writer.println(
"The users key is untrusted, either the user has reinstalled Signal or a third party sent this message.");
final var recipientName = getLegacyIdentifier(m.resolveSignalServiceAddress(e.getSender()));
@ -630,7 +627,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
private void printMention(
PlainTextWriter writer, SignalServiceDataMessage.Mention mention
) {
final var address = m.resolveSignalServiceAddress(new SignalServiceAddress(mention.getUuid(), null));
final var address = m.resolveSignalServiceAddress(mention.getUuid());
writer.println("- {}: {} (length: {})", formatContact(address), mention.getStart(), mention.getLength());
}