mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
parent
5cd5697aea
commit
7e7e4150e1
14 changed files with 167 additions and 7 deletions
|
@ -26,6 +26,7 @@ public class Commands {
|
|||
addCommand(new QuitGroupCommand());
|
||||
addCommand(new ReceiveCommand());
|
||||
addCommand(new RegisterCommand());
|
||||
addCommand(new RemoveContactCommand());
|
||||
addCommand(new RemoveDeviceCommand());
|
||||
addCommand(new RemoteDeleteCommand());
|
||||
addCommand(new RemovePinCommand());
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.asamk.signal.commands;
|
||||
|
||||
import net.sourceforge.argparse4j.impl.Arguments;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
import org.asamk.signal.util.CommandUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class RemoveContactCommand implements JsonRpcLocalCommand {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "removeContact";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.help("Remove the details of a given contact");
|
||||
subparser.addArgument("recipient").help("Contact number");
|
||||
subparser.addArgument("--forget")
|
||||
.action(Arguments.storeTrue())
|
||||
.help("Delete all data associated with this contact, including identity keys and sessions.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
var recipientString = ns.getString("recipient");
|
||||
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
|
||||
|
||||
var forget = Boolean.TRUE == ns.getBoolean("forget");
|
||||
try {
|
||||
if (forget) {
|
||||
m.deleteRecipient(recipient);
|
||||
} else {
|
||||
m.deleteContact(recipient);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IOErrorException("Remove contact error: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -381,6 +381,16 @@ public class DbusManagerImpl implements Manager {
|
|||
return new SendMessageResults(0, Map.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRecipient(final RecipientIdentifier.Single recipient) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteContact(final RecipientIdentifier.Single recipient) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContactName(
|
||||
final RecipientIdentifier.Single recipient, final String name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue