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

@ -14,7 +14,6 @@ import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.api.InactiveGroupLinkException;
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException;
import java.io.IOException;
import java.util.Map;
@ -70,8 +69,6 @@ public class JoinGroupCommand implements JsonRpcLocalCommand {
}
}
handleSendMessageResults(results.second().results());
} catch (GroupPatchNotAcceptedException e) {
throw new UserErrorException("Failed to join group, maybe already a member");
} catch (IOException e) {
throw new IOErrorException("Failed to send message: "
+ e.getMessage()

View file

@ -63,10 +63,10 @@ public class ListIdentitiesCommand implements JsonRpcLocalCommand {
} else {
final var writer = (JsonWriter) outputWriter;
final var jsonIdentities = identities.stream().map(id -> {
final var address = id.recipient().toSignalServiceAddress();
final var address = id.recipient();
var safetyNumber = Util.formatSafetyNumber(id.safetyNumber());
var scannableSafetyNumber = id.scannableSafetyNumber();
return new JsonIdentity(address.getNumber().orNull(),
return new JsonIdentity(address.getNumber().orElse(null),
address.getUuid().toString(),
Hex.toString(id.getFingerprint()),
safetyNumber,

View file

@ -8,7 +8,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.RegistrationManager;
import org.whispersystems.signalservice.api.push.exceptions.CaptchaRequiredException;
import org.asamk.signal.manager.api.CaptchaRequiredException;
import java.io.IOException;

View file

@ -5,12 +5,10 @@ import net.sourceforge.argparse4j.inf.Subparser;
import org.asamk.signal.commands.exceptions.CommandException;
import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.RegistrationManager;
import org.whispersystems.signalservice.api.KeyBackupServicePinException;
import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException;
import org.whispersystems.signalservice.internal.push.LockedException;
import org.asamk.signal.manager.api.IncorrectPinException;
import org.asamk.signal.manager.api.PinLockedException;
import java.io.IOException;
@ -36,15 +34,13 @@ public class VerifyCommand implements RegistrationCommand {
try {
final var manager = m.verifyAccount(verificationCode, pin);
manager.close();
} catch (LockedException e) {
} catch (PinLockedException e) {
throw new UserErrorException(
"Verification failed! This number is locked with a pin. Hours remaining until reset: "
+ (e.getTimeRemaining() / 1000 / 60 / 60)
+ "\nUse '--pin PIN_CODE' to specify the registration lock PIN");
} catch (KeyBackupServicePinException e) {
} catch (IncorrectPinException e) {
throw new UserErrorException("Verification failed! Invalid pin, tries remaining: " + e.getTriesRemaining());
} catch (KeyBackupSystemNoDataException e) {
throw new UnexpectedErrorException("Verification failed! No KBS data.", e);
} catch (IOException e) {
throw new IOErrorException("Verify error: " + e.getMessage(), e);
}