mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-06 22:10:38 +00:00
This reverts commit 8aed357994
.
This commit is contained in:
parent
0f437dbfd1
commit
5059925b22
20 changed files with 52 additions and 519 deletions
|
@ -1274,7 +1274,7 @@ public class Manager implements Closeable {
|
|||
) throws IOException, AttachmentInvalidException, InvalidNumberException {
|
||||
final var messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText);
|
||||
if (attachments != null) {
|
||||
List<SignalServiceAttachment> attachmentStreams = AttachmentUtils.getSignalServiceAttachments(attachments);
|
||||
var attachmentStreams = AttachmentUtils.getSignalServiceAttachments(attachments);
|
||||
|
||||
// Upload attachments here, so we only upload once even for multiple recipients
|
||||
var messageSender = createMessageSender();
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.net.URL;
|
||||
|
||||
public class AttachmentUtils {
|
||||
|
||||
|
@ -22,13 +21,8 @@ public class AttachmentUtils {
|
|||
for (var attachment : attachments) {
|
||||
try {
|
||||
signalServiceAttachments.add(createAttachment(new File(attachment)));
|
||||
} catch (IOException f) {
|
||||
// no such file, send it as URL
|
||||
try {
|
||||
signalServiceAttachments.add(createAttachment(new URL(attachment)));
|
||||
} catch (IOException e) {
|
||||
throw new AttachmentInvalidException(attachment, e);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new AttachmentInvalidException(attachment, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,39 +34,25 @@ public class AttachmentUtils {
|
|||
return createAttachment(streamDetails, Optional.of(attachmentFile.getName()));
|
||||
}
|
||||
|
||||
public static SignalServiceAttachmentStream createAttachment(URL aURL) throws IOException {
|
||||
final var streamDetails = Utils.createStreamDetailsFromURL(aURL);
|
||||
String path = aURL.getPath();
|
||||
String name = path.substring(path.lastIndexOf('/') + 1);
|
||||
return createAttachment(streamDetails, Optional.of(name));
|
||||
}
|
||||
|
||||
public static SignalServiceAttachmentStream createAttachment(
|
||||
StreamDetails streamDetails, Optional<String> name
|
||||
) {
|
||||
// TODO maybe add a parameter to set the voiceNote, borderless, preview, width, height, caption, blurHash options
|
||||
// TODO mabybe add a parameter to set the voiceNote, borderless, preview, width, height and caption option
|
||||
final var uploadTimestamp = System.currentTimeMillis();
|
||||
boolean voicenote = false;
|
||||
boolean borderless = false;
|
||||
Optional<byte[]> preview = Optional.absent();
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
Optional<String> caption = Optional.absent();
|
||||
Optional<String> blurHash = Optional.absent();
|
||||
final Optional<ResumableUploadSpec> resumableUploadSpec = Optional.absent();
|
||||
//ProgressListener listener = null; //Android OS
|
||||
//CancellationSignal cancellationSignal = null; //Android OS; Signal developers misspelled class name
|
||||
|
||||
return new SignalServiceAttachmentStream(streamDetails.getStream(),
|
||||
streamDetails.getContentType(),
|
||||
streamDetails.getLength(),
|
||||
name,
|
||||
voicenote,
|
||||
borderless,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
preview,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
0,
|
||||
uploadTimestamp,
|
||||
caption,
|
||||
blurHash,
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
|
||||
|
@ -37,13 +36,6 @@ public class Utils {
|
|||
return new StreamDetails(stream, mime, size);
|
||||
}
|
||||
|
||||
public static StreamDetails createStreamDetailsFromURL(URL aURL) throws IOException {
|
||||
InputStream stream = aURL.openStream();
|
||||
final var mime = aURL.openConnection().getContentType();
|
||||
final var size = aURL.openConnection().getContentLengthLong();
|
||||
return new StreamDetails(stream, mime, size);
|
||||
}
|
||||
|
||||
public static String computeSafetyNumber(
|
||||
boolean isUuidCapable,
|
||||
SignalServiceAddress ownAddress,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue