X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/f445cfb5c16ff0de5c96a9f96f5213e2cf5e770f..dbfa8bb66b194db87a78f59ae2e4e8041bef1b9a:/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 2442ddb6..4fd88819 100644 --- a/src/main/java/org/asamk/signal/util/ErrorUtils.java +++ b/src/main/java/org/asamk/signal/util/ErrorUtils.java @@ -1,6 +1,5 @@ package org.asamk.signal.util; -import org.asamk.signal.PlainTextWriter; import org.asamk.signal.commands.exceptions.CommandException; import org.asamk.signal.commands.exceptions.IOErrorException; import org.slf4j.Logger; @@ -12,6 +11,8 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import static org.asamk.signal.util.Util.getLegacyIdentifier; + public class ErrorUtils { private final static Logger logger = LoggerFactory.getLogger(ErrorUtils.class); @@ -19,12 +20,9 @@ public class ErrorUtils { private ErrorUtils() { } - public static void handleTimestampAndSendMessageResults( - PlainTextWriter writer, long timestamp, List results + public static void handleSendMessageResults( + List results ) throws CommandException { - if (timestamp != 0) { - writer.println("{}", timestamp); - } var errors = getErrorMessagesFromSendMessageResults(results); handleSendMessageResultErrors(errors); } @@ -42,17 +40,18 @@ public class ErrorUtils { } public static String getErrorMessageFromSendMessageResult(SendMessageResult result) { + var identifier = getLegacyIdentifier(result.getAddress()); if (result.isNetworkFailure()) { - return String.format("Network failure for \"%s\"", result.getAddress().getLegacyIdentifier()); + return String.format("Network failure for \"%s\"", identifier); } else if (result.isUnregisteredFailure()) { - return String.format("Unregistered user \"%s\"", result.getAddress().getLegacyIdentifier()); + return String.format("Unregistered user \"%s\"", identifier); } else if (result.getIdentityFailure() != null) { - return String.format("Untrusted Identity for \"%s\"", result.getAddress().getLegacyIdentifier()); + return String.format("Untrusted Identity for \"%s\"", identifier); } else if (result.getProofRequiredFailure() != null) { final var failure = result.getProofRequiredFailure(); return String.format( "CAPTCHA proof required for sending to \"%s\", available options \"%s\" with token \"%s\", or wait \"%d\" seconds", - result.getAddress().getLegacyIdentifier(), + identifier, failure.getOptions() .stream() .map(ProofRequiredException.Option::toString)