mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Use exit 4 when sending a single recipient message fails due to untrusted identity key
Fixes #88
This commit is contained in:
parent
e1134d832a
commit
06404667a1
6 changed files with 57 additions and 25 deletions
|
@ -33,18 +33,26 @@ public class ErrorUtils {
|
|||
public static List<String> getErrorMessagesFromSendMessageResults(List<SendMessageResult> results) {
|
||||
List<String> errors = new ArrayList<>();
|
||||
for (SendMessageResult result : results) {
|
||||
if (result.isNetworkFailure()) {
|
||||
errors.add(String.format("Network failure for \"%s\"", result.getAddress().getLegacyIdentifier()));
|
||||
} else if (result.isUnregisteredFailure()) {
|
||||
errors.add(String.format("Unregistered user \"%s\"", result.getAddress().getLegacyIdentifier()));
|
||||
} else if (result.getIdentityFailure() != null) {
|
||||
errors.add(String.format("Untrusted Identity for \"%s\"", result.getAddress().getLegacyIdentifier()));
|
||||
String error = getErrorMessageFromSendMessageResult(result);
|
||||
if (error != null) {
|
||||
errors.add(error);
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
public static String getErrorMessageFromSendMessageResult(SendMessageResult result) {
|
||||
if (result.isNetworkFailure()) {
|
||||
return String.format("Network failure for \"%s\"", result.getAddress().getLegacyIdentifier());
|
||||
} else if (result.isUnregisteredFailure()) {
|
||||
return String.format("Unregistered user \"%s\"", result.getAddress().getLegacyIdentifier());
|
||||
} else if (result.getIdentityFailure() != null) {
|
||||
return String.format("Untrusted Identity for \"%s\"", result.getAddress().getLegacyIdentifier());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int handleSendMessageResultErrors(List<String> errors) {
|
||||
if (errors.size() == 0) {
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue