mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Correctly send to multiple recipients
This commit is contained in:
parent
960e97bc12
commit
01702276c5
1 changed files with 12 additions and 4 deletions
|
@ -21,9 +21,10 @@ import net.sourceforge.argparse4j.impl.Arguments;
|
||||||
import net.sourceforge.argparse4j.inf.*;
|
import net.sourceforge.argparse4j.inf.*;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
import org.whispersystems.textsecure.api.TextSecureMessageSender;
|
||||||
import org.whispersystems.textsecure.api.crypto.UntrustedIdentityException;
|
|
||||||
import org.whispersystems.textsecure.api.messages.*;
|
import org.whispersystems.textsecure.api.messages.*;
|
||||||
import org.whispersystems.textsecure.api.messages.multidevice.TextSecureSyncMessage;
|
import org.whispersystems.textsecure.api.messages.multidevice.TextSecureSyncMessage;
|
||||||
|
import org.whispersystems.textsecure.api.push.TextSecureAddress;
|
||||||
|
import org.whispersystems.textsecure.api.push.exceptions.EncapsulatedExceptions;
|
||||||
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -150,13 +151,20 @@ public class Main {
|
||||||
messageBuilder.withAttachments(textSecureAttachments);
|
messageBuilder.withAttachments(textSecureAttachments);
|
||||||
}
|
}
|
||||||
TextSecureDataMessage message = messageBuilder.build();
|
TextSecureDataMessage message = messageBuilder.build();
|
||||||
|
|
||||||
|
List<TextSecureAddress> recipients = new ArrayList<>(ns.<String>getList("recipient").size());
|
||||||
for (String recipient : ns.<String>getList("recipient")) {
|
for (String recipient : ns.<String>getList("recipient")) {
|
||||||
try {
|
try {
|
||||||
messageSender.sendMessage(m.getPushAddress(recipient), message);
|
recipients.add(m.getPushAddress(recipient));
|
||||||
} catch (UntrustedIdentityException | IOException | InvalidNumberException e) {
|
} catch (InvalidNumberException e) {
|
||||||
System.out.println("Failed to send message to \"" + recipient + "\": " + e.getMessage());
|
System.out.println("Failed to send message to \"" + recipient + "\": " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
messageSender.sendMessage(recipients, message);
|
||||||
|
} catch (IOException | EncapsulatedExceptions e) {
|
||||||
|
System.out.println("Failed to send message: " + e.getMessage());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "receive":
|
case "receive":
|
||||||
if (!m.isRegistered()) {
|
if (!m.isRegistered()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue