]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/util/AttachmentUtils.java
Update libsignal-service
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / util / AttachmentUtils.java
index a94d76738f442040abf55b83158ad253e1c4d575..d06d87459c8738e2de035d80876be68f98035e03 100644 (file)
@@ -5,11 +5,11 @@ import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStre
 import org.whispersystems.signalservice.api.util.StreamDetails;
 import org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec;
 
-import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
+import java.util.UUID;
 
 public class AttachmentUtils {
 
@@ -19,17 +19,18 @@ public class AttachmentUtils {
         }
         final var signalServiceAttachments = new ArrayList<SignalServiceAttachmentStream>(attachments.size());
         for (var attachment : attachments) {
-            signalServiceAttachments.add(createAttachmentStream(new File(attachment)));
+            signalServiceAttachments.add(createAttachmentStream(attachment));
         }
         return signalServiceAttachments;
     }
 
-    public static SignalServiceAttachmentStream createAttachmentStream(File attachmentFile) throws AttachmentInvalidException {
+    public static SignalServiceAttachmentStream createAttachmentStream(String attachment) throws AttachmentInvalidException {
         try {
-            final var streamDetails = Utils.createStreamDetailsFromFile(attachmentFile);
-            return createAttachmentStream(streamDetails, Optional.of(attachmentFile.getName()));
+            final var streamDetails = Utils.createStreamDetails(attachment);
+
+            return createAttachmentStream(streamDetails.first(), streamDetails.second());
         } catch (IOException e) {
-            throw new AttachmentInvalidException(attachmentFile.toString(), e);
+            throw new AttachmentInvalidException(attachment, e);
         }
     }
 
@@ -49,6 +50,7 @@ public class AttachmentUtils {
                 false,
                 false,
                 false,
+                false,
                 preview,
                 0,
                 0,
@@ -57,6 +59,7 @@ public class AttachmentUtils {
                 blurHash,
                 null,
                 null,
-                resumableUploadSpec);
+                resumableUploadSpec,
+                UUID.randomUUID());
     }
 }