X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/6826e3cb49f42142d5d3201a7425a2180f496216..43bcc95713f14bdf6103d63d2daed66c3e7df502:/src/main/java/org/asamk/signal/util/ErrorUtils.java diff --git a/src/main/java/org/asamk/signal/util/ErrorUtils.java b/src/main/java/org/asamk/signal/util/ErrorUtils.java index 4fd88819..8a3de142 100644 --- a/src/main/java/org/asamk/signal/util/ErrorUtils.java +++ b/src/main/java/org/asamk/signal/util/ErrorUtils.java @@ -2,13 +2,16 @@ package org.asamk.signal.util; import org.asamk.signal.commands.exceptions.CommandException; import org.asamk.signal.commands.exceptions.IOErrorException; +import org.asamk.signal.manager.api.RecipientIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.whispersystems.signalservice.api.messages.SendMessageResult; import org.whispersystems.signalservice.api.push.exceptions.ProofRequiredException; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import static org.asamk.signal.util.Util.getLegacyIdentifier; @@ -21,13 +24,27 @@ public class ErrorUtils { } public static void handleSendMessageResults( - List results + Map> mapResults + ) throws CommandException { + List errors = getErrorMessagesFromSendMessageResults(mapResults); + handleSendMessageResultErrors(errors); + } + + public static void handleSendMessageResults( + Collection results ) throws CommandException { var errors = getErrorMessagesFromSendMessageResults(results); handleSendMessageResultErrors(errors); } - public static List getErrorMessagesFromSendMessageResults(List results) { + public static List getErrorMessagesFromSendMessageResults(final Map> mapResults) { + return mapResults.values() + .stream() + .flatMap(results -> getErrorMessagesFromSendMessageResults(results).stream()) + .collect(Collectors.toList()); + } + + public static List getErrorMessagesFromSendMessageResults(Collection results) { var errors = new ArrayList(); for (var result : results) { var error = getErrorMessageFromSendMessageResult(result);