mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Extract getTextSecureAttachments method
This commit is contained in:
parent
c1abc12907
commit
4b5bfcba80
1 changed files with 18 additions and 12 deletions
|
@ -119,20 +119,14 @@ public class Main {
|
||||||
if (ns.getBoolean("endsession")) {
|
if (ns.getBoolean("endsession")) {
|
||||||
sendEndSessionMessage(m, recipients);
|
sendEndSessionMessage(m, recipients);
|
||||||
} else {
|
} else {
|
||||||
final List<String> attachments = ns.getList("attachment");
|
|
||||||
List<TextSecureAttachment> textSecureAttachments = null;
|
List<TextSecureAttachment> textSecureAttachments = null;
|
||||||
if (attachments != null) {
|
|
||||||
textSecureAttachments = new ArrayList<>(attachments.size());
|
|
||||||
for (String attachment : attachments) {
|
|
||||||
try {
|
try {
|
||||||
textSecureAttachments.add(createAttachment(attachment));
|
textSecureAttachments = getTextSecureAttachments(ns.<String>getList("attachment"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Failed to add attachment \"" + attachment + "\": " + e.getMessage());
|
System.err.println("Failed to add attachment: " + e.getMessage());
|
||||||
System.err.println("Aborting sending.");
|
System.err.println("Aborting sending.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String messageText = ns.getString("message");
|
String messageText = ns.getString("message");
|
||||||
if (messageText == null) {
|
if (messageText == null) {
|
||||||
|
@ -270,6 +264,18 @@ public class Main {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<TextSecureAttachment> getTextSecureAttachments(List<String> attachments) {
|
||||||
|
private static List<TextSecureAttachment> getTextSecureAttachments(List<String> attachments) throws IOException {
|
||||||
|
List<TextSecureAttachment> textSecureAttachments = null;
|
||||||
|
if (attachments != null) {
|
||||||
|
textSecureAttachments = new ArrayList<>(attachments.size());
|
||||||
|
for (String attachment : attachments) {
|
||||||
|
textSecureAttachments.add(createAttachment(attachment));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return textSecureAttachments;
|
||||||
|
}
|
||||||
|
|
||||||
private static TextSecureAttachmentStream createAttachment(String attachment) throws IOException {
|
private static TextSecureAttachmentStream createAttachment(String attachment) throws IOException {
|
||||||
File attachmentFile = new File(attachment);
|
File attachmentFile = new File(attachment);
|
||||||
InputStream attachmentStream = new FileInputStream(attachmentFile);
|
InputStream attachmentStream = new FileInputStream(attachmentFile);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue