- @Override
- public void handleCommand(
- final Namespace ns, final Signal signal, final OutputWriter outputWriter
- ) throws CommandException {
- var groupId = CommandUtil.getGroupId(ns.getString("group-id"));
-
- var groupName = ns.getString("name");
- if (groupName == null) {
- groupName = "";
- }
-
- List<String> groupMembers = ns.getList("member");
- if (groupMembers == null) {
- groupMembers = new ArrayList<>();
- }
-
- var groupAvatar = ns.getString("avatar");
- if (groupAvatar == null) {
- groupAvatar = "";
- }
-
- try {
- var newGroupId = signal.updateGroup(groupId == null ? new byte[0] : groupId.serialize(),
- groupName,
- groupMembers,
- groupAvatar);
- if (groupId == null) {
- outputResult(outputWriter, null, GroupId.unknownVersion(newGroupId));
- }
- } catch (Signal.Error.AttachmentInvalid e) {
- throw new UserErrorException("Failed to add avatar attachment for group\": " + e.getMessage());
- } catch (DBusExecutionException e) {
- throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
- .getSimpleName() + ")", e);
- }
- }
-