Update libsignal-service-java

This commit is contained in:
AsamK 2022-05-14 15:08:19 +02:00
parent 5837a6982b
commit a80e18169a
14 changed files with 84 additions and 46 deletions

View file

@ -14,7 +14,7 @@ repositories {
}
dependencies {
implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_47")
implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_48")
implementation("com.fasterxml.jackson.core", "jackson-databind", "2.13.2.2")
implementation("com.google.protobuf", "protobuf-javalite", "3.11.4")
implementation("org.bouncycastle", "bcprov-jdk15on", "1.70")

View file

@ -540,7 +540,8 @@ class ManagerImpl implements Manager {
.resolveSignalServiceAddress(context.getRecipientHelper().resolveRecipient(quote.author())),
quote.message(),
List.of(),
resolveMentions(quote.mentions())));
resolveMentions(quote.mentions()),
SignalServiceDataMessage.Quote.Type.NORMAL));
}
if (message.sticker().isPresent()) {
final var sticker = message.sticker().get();

View file

@ -517,7 +517,7 @@ public record MessageEnvelope(
long expirationStartTimestamp,
Optional<RecipientAddress> destination,
Set<RecipientAddress> recipients,
Data message
Optional<Data> message
) {
static Sent from(
@ -534,7 +534,8 @@ public record MessageEnvelope(
.stream()
.map(d -> addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(d)))
.collect(Collectors.toSet()),
Data.from(sentMessage.getMessage(), recipientResolver, addressResolver, fileProvider));
sentMessage.getDataMessage()
.map(message -> Data.from(message, recipientResolver, addressResolver, fileProvider)));
}
}

View file

@ -31,7 +31,7 @@ public class ServiceConfig {
public static final AccountAttributes.Capabilities capabilities;
static {
capabilities = new AccountAttributes.Capabilities(false, true, false, true, true, true, true, false);
capabilities = new AccountAttributes.Capabilities(false, true, false, true, true, true, true, false, false);
try {
TrustStore contactTrustStore = new IasTrustStore();
@ -50,7 +50,8 @@ public class ServiceConfig {
try {
try {
org.signal.libsignal.internal.Native.UuidCiphertext_CheckValidContents(new byte[0]);
} catch (IllegalArgumentException ignored) {
} catch (Exception e) {
logger.trace("Expected exception when checking libsignal-client: {}", e.getMessage());
}
return true;
} catch (UnsatisfiedLinkError e) {

View file

@ -529,7 +529,8 @@ class GroupV2Helper {
final var today = currentTimeDays();
if (groupApiCredentials == null || !groupApiCredentials.containsKey(today)) {
// Returns credentials for the next 7 days
groupApiCredentials = dependencies.getGroupsV2Api().getCredentials(today);
final var isAci = true; // TODO enable group handling with PNI
groupApiCredentials = dependencies.getGroupsV2Api().getCredentials(today, isAci);
// TODO cache credentials on disk until they expire
}
var authCredentialResponse = groupApiCredentials.get(today);

View file

@ -122,7 +122,8 @@ public final class IncomingMessageHandler {
actions.add(new RetrieveProfileAction(recipientId));
exception = new UntrustedIdentityException(account.getRecipientStore()
.resolveRecipientAddress(recipientId), e.getSenderDevice());
} catch (ProtocolInvalidKeyIdException | ProtocolInvalidKeyException | ProtocolNoSessionException | ProtocolInvalidMessageException e) {
} catch (ProtocolInvalidKeyIdException | ProtocolInvalidKeyException | ProtocolNoSessionException |
ProtocolInvalidMessageException e) {
logger.debug("Failed to decrypt incoming message", e);
final var sender = account.getRecipientStore().resolveRecipient(e.getSender());
if (context.getContactHelper().isContactBlocked(sender)) {
@ -319,11 +320,13 @@ public final class IncomingMessageHandler {
if (syncMessage.getSent().isPresent()) {
var message = syncMessage.getSent().get();
final var destination = message.getDestination().orElse(null);
actions.addAll(handleSignalServiceDataMessage(message.getMessage(),
true,
sender,
destination == null ? null : context.getRecipientHelper().resolveRecipient(destination),
ignoreAttachments));
if (message.getDataMessage().isPresent()) {
actions.addAll(handleSignalServiceDataMessage(message.getDataMessage().get(),
true,
sender,
destination == null ? null : context.getRecipientHelper().resolveRecipient(destination),
ignoreAttachments));
}
}
if (syncMessage.getRequest().isPresent() && account.isMasterDevice()) {
var rm = syncMessage.getRequest().get();

View file

@ -616,10 +616,12 @@ public class SendHelper {
var address = account.getSelfAddress();
var transcript = new SentTranscriptMessage(Optional.of(address),
message.getTimestamp(),
message,
Optional.of(message),
message.getExpiresInSeconds(),
Map.of(address, true),
false);
false,
Optional.empty(),
Set.of());
var syncMessage = SignalServiceSyncMessage.forSentTranscript(transcript);
return sendSyncMessage(syncMessage);

View file

@ -3,6 +3,7 @@ package org.asamk.signal.manager.util;
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
import org.whispersystems.signalservice.api.push.ServiceId;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.UuidUtil;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -18,7 +19,7 @@ public class MessageCacheUtils {
try (var f = new FileInputStream(file)) {
var in = new DataInputStream(f);
var version = in.readInt();
if (version > 4) {
if (version > 5) {
return null;
}
var type = in.readInt();
@ -32,6 +33,10 @@ public class MessageCacheUtils {
// read legacy relay field
in.readUTF();
}
String destinationUuid = null;
if (version >= 5) {
destinationUuid = in.readUTF();
}
var timestamp = in.readLong();
byte[] content = null;
var contentLen = in.readInt();
@ -69,18 +74,20 @@ public class MessageCacheUtils {
content,
serverReceivedTimestamp,
serverDeliveredTimestamp,
uuid);
uuid,
destinationUuid == null ? UuidUtil.UNKNOWN_UUID.toString() : destinationUuid);
}
}
public static void storeEnvelope(SignalServiceEnvelope envelope, File file) throws IOException {
try (var f = new FileOutputStream(file)) {
try (var out = new DataOutputStream(f)) {
out.writeInt(4); // version
out.writeInt(5); // version
out.writeInt(envelope.getType());
out.writeUTF(envelope.getSourceE164().isPresent() ? envelope.getSourceE164().get() : "");
out.writeUTF(envelope.getSourceUuid().isPresent() ? envelope.getSourceUuid().get() : "");
out.writeInt(envelope.getSourceDevice());
out.writeUTF(envelope.getDestinationUuid() == null ? "" : envelope.getDestinationUuid());
out.writeLong(envelope.getTimestamp());
if (envelope.hasContent()) {
out.writeInt(envelope.getContent().length);