]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/util/MessageCacheUtils.java
Update libsignal-service-java
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / util / MessageCacheUtils.java
index a1f19274f08f06391f4c70b4b4ddb50b7bd7290c..347e3d819f463eb6d5dec9ac50d5c1c2e6589ab7 100644 (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);