Update libsignal-service-java

This commit is contained in:
AsamK 2021-05-19 22:51:35 +02:00
parent f445cfb5c1
commit 30690785fd
19 changed files with 71 additions and 42 deletions

View file

@ -12,6 +12,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);
@ -42,17 +44,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)

View file

@ -3,6 +3,7 @@ package org.asamk.signal.util;
import org.asamk.signal.manager.groups.GroupId;
import org.asamk.signal.manager.groups.GroupIdFormatException;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
public class Util {
@ -30,4 +31,8 @@ public class Util {
public static GroupId decodeGroupId(String groupId) throws GroupIdFormatException {
return GroupId.fromBase64(groupId);
}
public static String getLegacyIdentifier(final SignalServiceAddress address) {
return address.getNumber().or(() -> address.getUuid().get().toString());
}
}