- 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) {
+ throw new UserErrorException("Invalid group id: " + e.getMessage());
+ }
+
+ try {
+ var timestamp = signal.sendGroupMessage(messageText, attachments, groupId);
+ writer.println("{}", timestamp);
+ return;
+ } catch (DBusExecutionException e) {
+ throw new UnexpectedErrorException("Failed to send group message: " + e.getMessage());