X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/8867a7b9eeb3353d059613544899b262f4f47579..62687d103fab1ade650b920008060c220361d581:/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 e59c7f86..4a07e55e 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java @@ -26,7 +26,7 @@ import org.asamk.signal.manager.groups.LastGroupAdminException; import org.asamk.signal.manager.groups.NotAGroupMemberException; import org.asamk.signal.manager.storage.recipients.Profile; import org.asamk.signal.manager.storage.recipients.RecipientAddress; -import org.asamk.signal.util.ErrorUtils; +import org.asamk.signal.util.SendMessageResultUtils; import org.freedesktop.dbus.DBusPath; import org.freedesktop.dbus.connections.impl.DBusConnection; import org.freedesktop.dbus.exceptions.DBusException; @@ -191,9 +191,7 @@ public class DbusSignalImpl implements Signal { @Override public long sendMessage(final String message, final List attachments, final String recipient) { - var recipients = new ArrayList(1); - recipients.add(recipient); - return sendMessage(message, attachments, recipients); + return sendMessage(message, attachments, List.of(recipient)); } @Override @@ -219,9 +217,7 @@ public class DbusSignalImpl implements Signal { public long sendRemoteDeleteMessage( final long targetSentTimestamp, final String recipient ) { - var recipients = new ArrayList(1); - recipients.add(recipient); - return sendRemoteDeleteMessage(targetSentTimestamp, recipients); + return sendRemoteDeleteMessage(targetSentTimestamp, List.of(recipient)); } @Override @@ -266,9 +262,7 @@ public class DbusSignalImpl implements Signal { final long targetSentTimestamp, final String recipient ) { - var recipients = new ArrayList(1); - recipients.add(recipient); - return sendMessageReaction(emoji, remove, targetAuthor, targetSentTimestamp, recipients); + return sendMessageReaction(emoji, remove, targetAuthor, targetSentTimestamp, List.of(recipient)); } @Override @@ -301,10 +295,8 @@ public class DbusSignalImpl implements Signal { final String recipient, final boolean stop ) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity { try { - var recipients = new ArrayList(1); - recipients.add(recipient); final var results = m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START, - getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream() + getSingleRecipientIdentifiers(List.of(recipient), m.getSelfNumber()).stream() .map(RecipientIdentifier.class::cast) .collect(Collectors.toSet())); checkSendMessageResults(results.timestamp(), results.results()); @@ -499,11 +491,7 @@ public class DbusSignalImpl implements Signal { @Override public List getGroupIds() { var groups = m.getGroups(); - var ids = new ArrayList(groups.size()); - for (var group : groups) { - ids.add(group.groupId().serialize()); - } - return ids; + return groups.stream().map(g -> g.groupId().serialize()).toList(); } @Override @@ -595,9 +583,8 @@ public class DbusSignalImpl implements Signal { @Override public List isRegistered(List numbers) { - var results = new ArrayList(); if (numbers.isEmpty()) { - return results; + return List.of(); } Map> registered; @@ -610,7 +597,7 @@ public class DbusSignalImpl implements Signal { return numbers.stream().map(number -> { var uuid = registered.get(number).second(); return uuid != null; - }).collect(Collectors.toList()); + }).toList(); } @Override @@ -682,7 +669,7 @@ public class DbusSignalImpl implements Signal { .map(a -> a.number().orElse(null)) .filter(Objects::nonNull) .distinct() - .collect(Collectors.toList()); + .toList(); } @Override @@ -781,7 +768,7 @@ public class DbusSignalImpl implements Signal { } private static void checkSendMessageResult(long timestamp, SendMessageResult result) throws DBusExecutionException { - var error = ErrorUtils.getErrorMessageFromSendMessageResult(result); + var error = SendMessageResultUtils.getErrorMessageFromSendMessageResult(result); if (error == null) { return; @@ -805,7 +792,7 @@ public class DbusSignalImpl implements Signal { return; } - var errors = ErrorUtils.getErrorMessagesFromSendMessageResults(results); + var errors = SendMessageResultUtils.getErrorMessagesFromSendMessageResults(results); if (errors.size() == 0) { return; } @@ -828,7 +815,7 @@ public class DbusSignalImpl implements Signal { return; } - var errors = ErrorUtils.getErrorMessagesFromSendMessageResults(results); + var errors = SendMessageResultUtils.getErrorMessagesFromSendMessageResults(results); if (errors.size() == 0) { return; } @@ -844,7 +831,7 @@ public class DbusSignalImpl implements Signal { } private static List getRecipientStrings(final Set members) { - return members.stream().map(RecipientAddress::getLegacyIdentifier).collect(Collectors.toList()); + return members.stream().map(RecipientAddress::getLegacyIdentifier).toList(); } private static Set getSingleRecipientIdentifiers(