Remove libsignal-service from manager lib API

This commit is contained in:
AsamK 2021-11-06 13:29:26 +01:00
parent 9075cc1a30
commit 2ab42ca547
31 changed files with 269 additions and 96 deletions

View file

@ -2,10 +2,10 @@ package org.asamk.signal.util;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.api.InvalidNumberException;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.groups.GroupId;
import org.asamk.signal.manager.groups.GroupIdFormatException;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import java.util.Collection;
import java.util.HashSet;

View file

@ -2,11 +2,11 @@ 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.ProofRequiredException;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.SendMessageResult;
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;
@ -14,8 +14,6 @@ import java.util.List;
import java.util.Map;
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);
@ -57,9 +55,9 @@ public class ErrorUtils {
}
public static String getErrorMessageFromSendMessageResult(SendMessageResult result) {
var identifier = getLegacyIdentifier(result.getAddress());
if (result.getProofRequiredFailure() != null) {
final var failure = result.getProofRequiredFailure();
var identifier = result.address().getLegacyIdentifier();
if (result.proofRequiredFailure() != null) {
final var failure = result.proofRequiredFailure();
return String.format(
"CAPTCHA proof required for sending to \"%s\", available options \"%s\" with challenge token \"%s\", or wait \"%d\" seconds.\n"
+ (
@ -83,7 +81,7 @@ public class ErrorUtils {
return String.format("Network failure for \"%s\"", identifier);
} else if (result.isUnregisteredFailure()) {
return String.format("Unregistered user \"%s\"", identifier);
} else if (result.getIdentityFailure() != null) {
} else if (result.isIdentityFailure()) {
return String.format("Untrusted Identity for \"%s\"", identifier);
}
return null;

View file

@ -5,8 +5,6 @@ import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
@ -59,10 +57,6 @@ public class Util {
return f.toString();
}
public static String getLegacyIdentifier(final SignalServiceAddress address) {
return address.getNumber().or(() -> address.getUuid().toString());
}
public static ObjectMapper createJsonObjectMapper() {
var objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.PUBLIC_ONLY);