mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Add MultiAccountManager
This commit is contained in:
parent
6261934dda
commit
4a1af0786c
18 changed files with 221 additions and 131 deletions
|
@ -3,8 +3,8 @@ package org.asamk.signal.dbus;
|
|||
import org.asamk.SignalControl;
|
||||
import org.asamk.signal.BaseConfig;
|
||||
import org.asamk.signal.DbusConfig;
|
||||
import org.asamk.signal.commands.SignalCreator;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.MultiAccountManager;
|
||||
import org.asamk.signal.manager.ProvisioningManager;
|
||||
import org.asamk.signal.manager.RegistrationManager;
|
||||
import org.asamk.signal.manager.UserAlreadyExists;
|
||||
|
@ -21,11 +21,11 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||
|
||||
private final SignalCreator c;
|
||||
private final MultiAccountManager c;
|
||||
|
||||
private final String objectPath;
|
||||
|
||||
public DbusSignalControlImpl(final SignalCreator c, final String objectPath) {
|
||||
public DbusSignalControlImpl(final MultiAccountManager c, final String objectPath) {
|
||||
this.c = c;
|
||||
this.objectPath = objectPath;
|
||||
}
|
||||
|
@ -75,8 +75,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
final String number, final String verificationCode, final String pin
|
||||
) throws Error.Failure, Error.InvalidNumber {
|
||||
try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) {
|
||||
final Manager manager = registrationManager.verifyAccount(verificationCode, pin);
|
||||
c.addManager(manager);
|
||||
registrationManager.verifyAccount(verificationCode, pin);
|
||||
} catch (IOException | PinLockedException | IncorrectPinException e) {
|
||||
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
|
||||
}
|
||||
|
@ -89,8 +88,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
final URI deviceLinkUri = provisioningManager.getDeviceLinkUri();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
final Manager manager = provisioningManager.finishDeviceLink(newDeviceName);
|
||||
c.addManager(manager);
|
||||
provisioningManager.finishDeviceLink(newDeviceName);
|
||||
} catch (IOException | TimeoutException | UserAlreadyExists e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -129,9 +129,7 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void submitRateLimitChallenge(String challenge, String captchaString) {
|
||||
final var captcha = captchaString == null ? null : captchaString.replace("signalcaptcha://", "");
|
||||
|
||||
public void submitRateLimitChallenge(String challenge, String captcha) {
|
||||
try {
|
||||
m.submitRateLimitRecaptchaChallenge(challenge, captcha);
|
||||
} catch (IOException e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue