X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/6a1b7dc5975161f59fbb1012dd340c7b6e0198f7..b738f5740c94fe7a5df9e322e1345a99ef0c5ce5:/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java diff --git a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java index 77b3bc99..d19116a4 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java @@ -2,10 +2,11 @@ package org.asamk.signal.dbus; import org.asamk.Signal; import org.asamk.signal.manager.AttachmentInvalidException; -import org.asamk.signal.manager.GroupNotFoundException; import org.asamk.signal.manager.Manager; -import org.asamk.signal.manager.NotAGroupMemberException; -import org.asamk.signal.storage.groups.GroupInfo; +import org.asamk.signal.manager.groups.GroupId; +import org.asamk.signal.manager.groups.GroupNotFoundException; +import org.asamk.signal.manager.groups.NotAGroupMemberException; +import org.asamk.signal.manager.storage.groups.GroupInfo; import org.asamk.signal.util.ErrorUtils; import org.freedesktop.dbus.exceptions.DBusExecutionException; import org.whispersystems.libsignal.util.Pair; @@ -44,7 +45,9 @@ public class DbusSignalImpl implements Signal { return sendMessage(message, attachments, recipients); } - private static void checkSendMessageResults(long timestamp, List results) throws DBusExecutionException { + private static void checkSendMessageResults( + long timestamp, List results + ) throws DBusExecutionException { List errors = ErrorUtils.getErrorMessagesFromSendMessageResults(results); if (errors.size() == 0) { return; @@ -90,7 +93,9 @@ public class DbusSignalImpl implements Signal { @Override public long sendGroupMessage(final String message, final List attachments, final byte[] groupId) { try { - Pair> results = m.sendGroupMessage(message, attachments, groupId); + Pair> results = m.sendGroupMessage(message, + attachments, + GroupId.unknownVersion(groupId)); checkSendMessageResults(results.first(), results.second()); return results.first(); } catch (IOException e) { @@ -132,7 +137,7 @@ public class DbusSignalImpl implements Signal { @Override public void setGroupBlocked(final byte[] groupId, final boolean blocked) { try { - m.setGroupBlocked(groupId, blocked); + m.setGroupBlocked(GroupId.unknownVersion(groupId), blocked); } catch (GroupNotFoundException e) { throw new Error.GroupNotFound(e.getMessage()); } @@ -143,14 +148,14 @@ public class DbusSignalImpl implements Signal { List groups = m.getGroups(); List ids = new ArrayList<>(groups.size()); for (GroupInfo group : groups) { - ids.add(group.groupId); + ids.add(group.getGroupId().serialize()); } return ids; } @Override public String getGroupName(final byte[] groupId) { - GroupInfo group = m.getGroup(groupId); + GroupInfo group = m.getGroup(GroupId.unknownVersion(groupId)); if (group == null) { return ""; } else { @@ -160,20 +165,38 @@ public class DbusSignalImpl implements Signal { @Override public List getGroupMembers(final byte[] groupId) { - GroupInfo group = m.getGroup(groupId); + GroupInfo group = m.getGroup(GroupId.unknownVersion(groupId)); if (group == null) { return Collections.emptyList(); } else { - return group.getMembers().stream().map(m::resolveSignalServiceAddress).map(SignalServiceAddress::getLegacyIdentifier).collect(Collectors.toList()); + return group.getMembers() + .stream() + .map(m::resolveSignalServiceAddress) + .map(SignalServiceAddress::getLegacyIdentifier) + .collect(Collectors.toList()); } } @Override - public byte[] updateGroup(final byte[] groupId, final String name, final List members, final String avatar) { + public byte[] updateGroup(byte[] groupId, String name, List members, String avatar) { try { - final Pair> results = m.updateGroup(groupId, name, members, avatar); + if (groupId.length == 0) { + groupId = null; + } + if (name.isEmpty()) { + name = null; + } + if (members.isEmpty()) { + members = null; + } + if (avatar.isEmpty()) { + avatar = null; + } + final Pair> results = m.updateGroup(groupId == null + ? null + : GroupId.unknownVersion(groupId), name, members, avatar); checkSendMessageResults(0, results.second()); - return results.first(); + return results.first().serialize(); } catch (IOException e) { throw new Error.Failure(e.getMessage()); } catch (GroupNotFoundException | NotAGroupMemberException e) {