- try {
- List<String> attachments = ns.getList("attachment");
- if (attachments == null) {
- attachments = new ArrayList<>();
+ List<String> attachments = ns.getList("attachment");
+ if (attachments == null) {
+ attachments = List.of();
+ }
+
+ final var writer = new PlainTextWriterImpl(System.out);
+
+ if (groupIdString != null) {
+ byte[] groupId;
+ try {
+ groupId = Util.decodeGroupId(groupIdString).serialize();
+ } catch (GroupIdFormatException e) {
+ handleGroupIdFormatException(e);
+ return 1;
+ }
+
+ try {
+ var timestamp = signal.sendGroupMessage(messageText, attachments, groupId);
+ writer.println("{}", timestamp);
+ return 0;
+ } catch (AssertionError e) {
+ handleAssertionError(e);
+ return 1;
+ } catch (DBusExecutionException e) {
+ System.err.println("Failed to send group message: " + e.getMessage());
+ return 2;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return 3;