]> nmode's Git Repositories - signal-cli/commitdiff
Update libsignal-service-java
authorAsamK <asamk@gmx.de>
Tue, 2 Aug 2022 21:20:26 +0000 (23:20 +0200)
committerAsamK <asamk@gmx.de>
Wed, 3 Aug 2022 16:02:56 +0000 (18:02 +0200)
graalvm-config-dir/reflect-config.json
lib/build.gradle.kts
lib/src/main/java/org/asamk/signal/manager/helper/SendHelper.java
lib/src/main/java/org/asamk/signal/manager/storage/sendLog/MessageSendLogEntry.java
lib/src/main/java/org/asamk/signal/manager/storage/sendLog/MessageSendLogStore.java
lib/src/main/java/org/asamk/signal/manager/util/MessageCacheUtils.java

index 4c41de46f1e23d4c0d0418f1068d675f82e1bc2e..c223851bef52c381c75ee68b3546aae42be799ff 100644 (file)
     {"name":"sourceE164_"}, 
     {"name":"sourceUuid_"}, 
     {"name":"timestamp_"}, 
-    {"name":"type_"}
+    {"name":"type_"}, 
+    {"name":"urgent_"}
   ]
 },
 {
   "name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$SyncMessage$Sent",
   "fields":[
     {"name":"bitField0_"}, 
+    {"name":"destinationE164_"}, 
     {"name":"destinationUuid_"}, 
     {"name":"expirationStartTimestamp_"}, 
     {"name":"isRecipientUpdate_"}, 
index eb68b368d175765f04f0cb1d45d4990445de9e0c..70de8dd7fe6e55e8c53c9be611543ba393b9fb44 100644 (file)
@@ -14,7 +14,7 @@ repositories {
 }
 
 dependencies {
-    implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_52")
+    implementation("com.github.turasa", "signal-service-java", "2.15.3_unofficial_53")
     implementation("com.fasterxml.jackson.core", "jackson-databind", "2.13.3")
     implementation("com.google.protobuf", "protobuf-javalite", "3.11.4")
     implementation("org.bouncycastle", "bcprov-jdk15on", "1.70")
index f71133ae097abbc95f7c7a4cf0a7c6297df0160f..717db81219c4a50be8923d39343c3191d77c8fdf 100644 (file)
@@ -123,7 +123,7 @@ public class SendHelper {
                 (messageSender, address, unidentifiedAccess) -> messageSender.sendReceipt(address,
                         unidentifiedAccess,
                         receiptMessage));
-        messageSendLogStore.insertIfPossible(receiptMessage.getWhen(), result, ContentHint.IMPLICIT);
+        messageSendLogStore.insertIfPossible(receiptMessage.getWhen(), result, ContentHint.IMPLICIT, false);
         handleSendMessageResult(result);
         return result;
     }
@@ -140,7 +140,8 @@ public class SendHelper {
                         unidentifiedAccess,
                         ContentHint.IMPLICIT,
                         message,
-                        SignalServiceMessageSender.IndividualSendEvents.EMPTY));
+                        SignalServiceMessageSender.IndividualSendEvents.EMPTY,
+                        false));
     }
 
     public SendMessageResult sendRetryReceipt(
@@ -237,7 +238,8 @@ public class SendHelper {
                             timestamp,
                             messageSendLogEntry.content(),
                             messageSendLogEntry.contentHint(),
-                            Optional.empty()));
+                            Optional.empty(),
+                            messageSendLogEntry.urgent()));
         }
 
         final var groupId = messageSendLogEntry.groupId().get();
@@ -266,7 +268,8 @@ public class SendHelper {
                         timestamp,
                         contentToSend,
                         messageSendLogEntry.contentHint(),
-                        Optional.of(group.getGroupId().serialize())));
+                        Optional.of(group.getGroupId().serialize()),
+                        messageSendLogEntry.urgent()));
 
         if (result.isSuccess()) {
             final var address = context.getRecipientHelper().resolveSignalServiceAddress(recipientId);
@@ -315,6 +318,7 @@ public class SendHelper {
         final var messageSendLogStore = account.getMessageSendLogStore();
         final AtomicLong entryId = new AtomicLong(-1);
 
+        final var urgent = true;
         final LegacySenderHandler legacySender = (recipients, unidentifiedAccess, isRecipientUpdate) -> messageSender.sendDataMessage(
                 recipients,
                 unidentifiedAccess,
@@ -328,14 +332,16 @@ public class SendHelper {
                         if (entryId.get() == -1) {
                             final var newId = messageSendLogStore.insertIfPossible(message.getTimestamp(),
                                     sendResult,
-                                    contentHint);
+                                    contentHint,
+                                    urgent);
                             entryId.set(newId);
                         } else {
                             messageSendLogStore.addRecipientToExistingEntryIfPossible(entryId.get(), sendResult);
                         }
                     }
                 },
-                () -> false);
+                () -> false,
+                urgent);
         final SenderKeySenderHandler senderKeySender = (distId, recipients, unidentifiedAccess, isRecipientUpdate) -> {
             final var res = messageSender.sendGroupDataMessage(distId,
                     recipients,
@@ -343,10 +349,14 @@ public class SendHelper {
                     isRecipientUpdate,
                     contentHint,
                     message,
-                    SignalServiceMessageSender.SenderKeyGroupEvents.EMPTY);
+                    SignalServiceMessageSender.SenderKeyGroupEvents.EMPTY,
+                    urgent);
             synchronized (entryId) {
                 if (entryId.get() == -1) {
-                    final var newId = messageSendLogStore.insertIfPossible(message.getTimestamp(), res, contentHint);
+                    final var newId = messageSendLogStore.insertIfPossible(message.getTimestamp(),
+                            res,
+                            contentHint,
+                            urgent);
                     entryId.set(newId);
                 } else {
                     messageSendLogStore.addRecipientToExistingEntryIfPossible(entryId.get(), res);
@@ -582,13 +592,15 @@ public class SendHelper {
             SignalServiceDataMessage message, RecipientId recipientId
     ) {
         final var messageSendLogStore = account.getMessageSendLogStore();
+        final var urgent = true;
         final var result = handleSendMessage(recipientId,
                 (messageSender, address, unidentifiedAccess) -> messageSender.sendDataMessage(address,
                         unidentifiedAccess,
                         ContentHint.RESENDABLE,
                         message,
-                        SignalServiceMessageSender.IndividualSendEvents.EMPTY));
-        messageSendLogStore.insertIfPossible(message.getTimestamp(), result, ContentHint.RESENDABLE);
+                        SignalServiceMessageSender.IndividualSendEvents.EMPTY,
+                        urgent));
+        messageSendLogStore.insertIfPossible(message.getTimestamp(), result, ContentHint.RESENDABLE, urgent);
         handleSendMessageResult(result);
         return result;
     }
index 31a4252aa943503910cc9a21f572a62e9a20d3e5..67ca5cd454925d54cbe3a3bbee5b33f80b087128 100644 (file)
@@ -7,5 +7,5 @@ import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
 import java.util.Optional;
 
 public record MessageSendLogEntry(
-        Optional<GroupId> groupId, SignalServiceProtos.Content content, ContentHint contentHint
+        Optional<GroupId> groupId, SignalServiceProtos.Content content, ContentHint contentHint, boolean urgent
 ) {}
index c893f09ccbe6da06d187e99d2bc924e9aa5dcdbb..b53c5ac0040451bb9914566b53e0b396c35aa8e7 100644 (file)
@@ -117,7 +117,8 @@ public class MessageSendLogStore implements AutoCloseable {
                         return null;
                     }
                     final var contentHint = ContentHint.fromType(resultSet.getInt("content_hint"));
-                    return new MessageSendLogEntry(groupId, content, contentHint);
+                    final var urgent = true; // TODO
+                    return new MessageSendLogEntry(groupId, content, contentHint, urgent);
                 })) {
                     return result.filter(Objects::nonNull)
                             .filter(e -> !isSenderKey || e.groupId().isPresent())
@@ -131,7 +132,7 @@ public class MessageSendLogStore implements AutoCloseable {
     }
 
     public long insertIfPossible(
-            long sentTimestamp, SendMessageResult sendMessageResult, ContentHint contentHint
+            long sentTimestamp, SendMessageResult sendMessageResult, ContentHint contentHint, boolean urgent
     ) {
         final RecipientDevices recipientDevice = getRecipientDevices(sendMessageResult);
         if (recipientDevice == null) {
@@ -141,11 +142,12 @@ public class MessageSendLogStore implements AutoCloseable {
         return insert(List.of(recipientDevice),
                 sentTimestamp,
                 sendMessageResult.getSuccess().getContent().get(),
-                contentHint);
+                contentHint,
+                urgent);
     }
 
     public long insertIfPossible(
-            long sentTimestamp, List<SendMessageResult> sendMessageResults, ContentHint contentHint
+            long sentTimestamp, List<SendMessageResult> sendMessageResults, ContentHint contentHint, boolean urgent
     ) {
         final var recipientDevices = sendMessageResults.stream()
                 .map(this::getRecipientDevices)
@@ -161,7 +163,7 @@ public class MessageSendLogStore implements AutoCloseable {
                 .findFirst()
                 .get();
 
-        return insert(recipientDevices, sentTimestamp, content, contentHint);
+        return insert(recipientDevices, sentTimestamp, content, contentHint, urgent);
     }
 
     public void addRecipientToExistingEntryIfPossible(final long contentId, final SendMessageResult sendMessageResult) {
@@ -272,10 +274,12 @@ public class MessageSendLogStore implements AutoCloseable {
             final List<RecipientDevices> recipientDevices,
             final long sentTimestamp,
             final SignalServiceProtos.Content content,
-            final ContentHint contentHint
+            final ContentHint contentHint,
+            final boolean urgent
     ) {
         byte[] groupId = getGroupId(content);
 
+        // TODO store urgent
         final var sql = """
                         INSERT INTO %s (timestamp, group_id, content, content_hint)
                         VALUES (?,?,?,?)
index 347e3d819f463eb6d5dec9ac50d5c1c2e6589ab7..43badfa6771bbb19d99aeede9aae833e338254d9 100644 (file)
@@ -19,7 +19,8 @@ public class MessageCacheUtils {
         try (var f = new FileInputStream(file)) {
             var in = new DataInputStream(f);
             var version = in.readInt();
-            if (version > 5) {
+            if (version > 6) {
+                // Unsupported envelope version
                 return null;
             }
             var type = in.readInt();
@@ -63,6 +64,10 @@ public class MessageCacheUtils {
             if (version >= 4) {
                 serverDeliveredTimestamp = in.readLong();
             }
+            boolean isUrgent = true;
+            if (version >= 6) {
+                isUrgent = in.readBoolean();
+            }
             Optional<SignalServiceAddress> addressOptional = sourceServiceId == null
                     ? Optional.empty()
                     : Optional.of(new SignalServiceAddress(sourceServiceId, source));
@@ -75,14 +80,15 @@ public class MessageCacheUtils {
                     serverReceivedTimestamp,
                     serverDeliveredTimestamp,
                     uuid,
-                    destinationUuid == null ? UuidUtil.UNKNOWN_UUID.toString() : destinationUuid);
+                    destinationUuid == null ? UuidUtil.UNKNOWN_UUID.toString() : destinationUuid,
+                    isUrgent);
         }
     }
 
     public static void storeEnvelope(SignalServiceEnvelope envelope, File file) throws IOException {
         try (var f = new FileOutputStream(file)) {
             try (var out = new DataOutputStream(f)) {
-                out.writeInt(5); // version
+                out.writeInt(6); // version
                 out.writeInt(envelope.getType());
                 out.writeUTF(envelope.getSourceE164().isPresent() ? envelope.getSourceE164().get() : "");
                 out.writeUTF(envelope.getSourceUuid().isPresent() ? envelope.getSourceUuid().get() : "");
@@ -105,6 +111,7 @@ public class MessageCacheUtils {
                 var uuid = envelope.getServerGuid();
                 out.writeUTF(uuid == null ? "" : uuid);
                 out.writeLong(envelope.getServerDeliveredTimestamp());
+                out.writeBoolean(envelope.isUrgent());
             }
         }
     }