Implement JsonRpc command for commands without output

This commit is contained in:
AsamK 2021-08-10 15:26:43 +02:00
parent 6826e3cb49
commit 5d8d0dcad6
13 changed files with 15 additions and 15 deletions

View file

@ -17,7 +17,7 @@ import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
public class AddDeviceCommand implements LocalCommand { public class AddDeviceCommand implements JsonRpcLocalCommand {
private final static Logger logger = LoggerFactory.getLogger(AddDeviceCommand.class); private final static Logger logger = LoggerFactory.getLogger(AddDeviceCommand.class);

View file

@ -15,7 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.whispersystems.signalservice.api.util.InvalidNumberException; import org.whispersystems.signalservice.api.util.InvalidNumberException;
public class BlockCommand implements LocalCommand { public class BlockCommand implements JsonRpcLocalCommand {
private final static Logger logger = LoggerFactory.getLogger(BlockCommand.class); private final static Logger logger = LoggerFactory.getLogger(BlockCommand.class);

View file

@ -10,7 +10,7 @@ import org.asamk.signal.manager.Manager;
import java.io.IOException; import java.io.IOException;
public class RemoveDeviceCommand implements LocalCommand { public class RemoveDeviceCommand implements JsonRpcLocalCommand {
public RemoveDeviceCommand(final OutputWriter outputWriter) { public RemoveDeviceCommand(final OutputWriter outputWriter) {
} }

View file

@ -13,7 +13,7 @@ import org.whispersystems.signalservice.internal.contacts.crypto.Unauthenticated
import java.io.IOException; import java.io.IOException;
public class RemovePinCommand implements LocalCommand { public class RemovePinCommand implements JsonRpcLocalCommand {
public RemovePinCommand(final OutputWriter outputWriter) { public RemovePinCommand(final OutputWriter outputWriter) {
} }

View file

@ -12,7 +12,7 @@ import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
import java.io.IOException; import java.io.IOException;
public class SendContactsCommand implements LocalCommand { public class SendContactsCommand implements JsonRpcLocalCommand {
public SendContactsCommand(final OutputWriter outputWriter) { public SendContactsCommand(final OutputWriter outputWriter) {
} }

View file

@ -10,7 +10,7 @@ import org.asamk.signal.manager.Manager;
import java.io.IOException; import java.io.IOException;
public class SendSyncRequestCommand implements LocalCommand { public class SendSyncRequestCommand implements JsonRpcLocalCommand {
public SendSyncRequestCommand(final OutputWriter outputWriter) { public SendSyncRequestCommand(final OutputWriter outputWriter) {
} }

View file

@ -20,7 +20,7 @@ import org.whispersystems.signalservice.api.util.InvalidNumberException;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
public class SendTypingCommand implements LocalCommand { public class SendTypingCommand implements JsonRpcLocalCommand {
public SendTypingCommand(final OutputWriter outputWriter) { public SendTypingCommand(final OutputWriter outputWriter) {
} }

View file

@ -13,21 +13,21 @@ import org.whispersystems.signalservice.internal.contacts.crypto.Unauthenticated
import java.io.IOException; import java.io.IOException;
public class SetPinCommand implements LocalCommand { public class SetPinCommand implements JsonRpcLocalCommand {
public SetPinCommand(final OutputWriter outputWriter) { public SetPinCommand(final OutputWriter outputWriter) {
} }
public static void attachToSubparser(final Subparser subparser) { public static void attachToSubparser(final Subparser subparser) {
subparser.help("Set a registration lock pin, to prevent others from registering this number."); subparser.help("Set a registration lock pin, to prevent others from registering this number.");
subparser.addArgument("registrationLockPin") subparser.addArgument("pin")
.help("The registration lock PIN, that will be required for new registrations (resets after 7 days of inactivity)"); .help("The registration lock PIN, that will be required for new registrations (resets after 7 days of inactivity)");
} }
@Override @Override
public void handleCommand(final Namespace ns, final Manager m) throws CommandException { public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
try { try {
var registrationLockPin = ns.getString("registrationLockPin"); var registrationLockPin = ns.getString("pin");
m.setRegistrationLockPin(Optional.of(registrationLockPin)); m.setRegistrationLockPin(Optional.of(registrationLockPin));
} catch (UnauthenticatedResponseException e) { } catch (UnauthenticatedResponseException e) {
throw new UnexpectedErrorException("Set pin error failed with unauthenticated response: " + e.getMessage()); throw new UnexpectedErrorException("Set pin error failed with unauthenticated response: " + e.getMessage());

View file

@ -13,7 +13,7 @@ import org.whispersystems.signalservice.api.util.InvalidNumberException;
import java.util.Locale; import java.util.Locale;
public class TrustCommand implements LocalCommand { public class TrustCommand implements JsonRpcLocalCommand {
public TrustCommand(final OutputWriter outputWriter) { public TrustCommand(final OutputWriter outputWriter) {
} }

View file

@ -15,7 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.whispersystems.signalservice.api.util.InvalidNumberException; import org.whispersystems.signalservice.api.util.InvalidNumberException;
public class UnblockCommand implements LocalCommand { public class UnblockCommand implements JsonRpcLocalCommand {
private final static Logger logger = LoggerFactory.getLogger(UnblockCommand.class); private final static Logger logger = LoggerFactory.getLogger(UnblockCommand.class);

View file

@ -10,7 +10,7 @@ import org.asamk.signal.manager.Manager;
import java.io.IOException; import java.io.IOException;
public class UpdateAccountCommand implements LocalCommand { public class UpdateAccountCommand implements JsonRpcLocalCommand {
public UpdateAccountCommand(final OutputWriter outputWriter) { public UpdateAccountCommand(final OutputWriter outputWriter) {
} }

View file

@ -13,7 +13,7 @@ import org.whispersystems.signalservice.api.util.InvalidNumberException;
import java.io.IOException; import java.io.IOException;
public class UpdateContactCommand implements LocalCommand { public class UpdateContactCommand implements JsonRpcLocalCommand {
public UpdateContactCommand(final OutputWriter outputWriter) { public UpdateContactCommand(final OutputWriter outputWriter) {
} }

View file

@ -13,7 +13,7 @@ import org.whispersystems.libsignal.util.guava.Optional;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
public class UpdateProfileCommand implements LocalCommand { public class UpdateProfileCommand implements JsonRpcLocalCommand {
public UpdateProfileCommand(final OutputWriter outputWriter) { public UpdateProfileCommand(final OutputWriter outputWriter) {
} }