]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/SendCommand.java
Refactor to use GroupId class to wrap the byte array
[signal-cli] / src / main / java / org / asamk / signal / commands / SendCommand.java
index 43166b5b1492ae24b610448355d7b1b9605b6a50..04b064340c188cb4a90687c3638191db29ba3b06 100644 (file)
@@ -5,7 +5,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
 import net.sourceforge.argparse4j.inf.Subparser;
 
 import org.asamk.Signal;
-import org.asamk.signal.util.GroupIdFormatException;
+import org.asamk.signal.manager.GroupIdFormatException;
 import org.asamk.signal.util.IOUtils;
 import org.asamk.signal.util.Util;
 import org.freedesktop.dbus.exceptions.DBusExecutionException;
@@ -22,16 +22,10 @@ public class SendCommand implements DbusCommand {
 
     @Override
     public void attachToSubparser(final Subparser subparser) {
-        subparser.addArgument("-g", "--group")
-                .help("Specify the recipient group ID.");
-        subparser.addArgument("recipient")
-                .help("Specify the recipients' phone number.")
-                .nargs("*");
-        subparser.addArgument("-m", "--message")
-                .help("Specify the message, if missing standard input is used.");
-        subparser.addArgument("-a", "--attachment")
-                .nargs("*")
-                .help("Add file as attachment");
+        subparser.addArgument("-g", "--group").help("Specify the recipient group ID.");
+        subparser.addArgument("recipient").help("Specify the recipients' phone number.").nargs("*");
+        subparser.addArgument("-m", "--message").help("Specify the message, if missing standard input is used.");
+        subparser.addArgument("-a", "--attachment").nargs("*").help("Add file as attachment");
         subparser.addArgument("-e", "--endsession")
                 .help("Clear session state and send end session message.")
                 .action(Arguments.storeTrue());
@@ -44,7 +38,9 @@ public class SendCommand implements DbusCommand {
             return 1;
         }
 
-        if ((ns.getList("recipient") == null || ns.getList("recipient").size() == 0) && (ns.getBoolean("endsession") || ns.getString("group") == null)) {
+        if ((ns.getList("recipient") == null || ns.getList("recipient").size() == 0) && (
+                ns.getBoolean("endsession") || ns.getString("group") == null
+        )) {
             System.err.println("No recipients given");
             System.err.println("Aborting sending.");
             return 1;
@@ -83,7 +79,7 @@ public class SendCommand implements DbusCommand {
             if (ns.getString("group") != null) {
                 byte[] groupId;
                 try {
-                    groupId = Util.decodeGroupId(ns.getString("group"));
+                    groupId = Util.decodeGroupId(ns.getString("group")).serialize();
                 } catch (GroupIdFormatException e) {
                     handleGroupIdFormatException(e);
                     return 1;