mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Add sendMessageRequestResponse command
This commit is contained in:
parent
2c0ad7feb7
commit
d84362eb0f
11 changed files with 210 additions and 0 deletions
|
@ -39,6 +39,7 @@ public class Commands {
|
|||
addCommand(new RemoteDeleteCommand());
|
||||
addCommand(new SendCommand());
|
||||
addCommand(new SendContactsCommand());
|
||||
addCommand(new SendMessageRequestResponseCommand());
|
||||
addCommand(new SendPaymentNotificationCommand());
|
||||
addCommand(new SendReactionCommand());
|
||||
addCommand(new SendReceiptCommand());
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package org.asamk.signal.commands;
|
||||
|
||||
enum MessageRequestResponseType {
|
||||
ACCEPT {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "accept";
|
||||
}
|
||||
},
|
||||
DELETE {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "delete";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.manager.Manager;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope.Sync.MessageRequestResponse.Type;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
import org.asamk.signal.util.CommandUtil;
|
||||
|
||||
public class SendMessageRequestResponseCommand implements JsonRpcLocalCommand {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "sendMessageRequestResponse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.help("Send response to a message request to linked devices.");
|
||||
subparser.addArgument("-g", "--group-id", "--group").help("Specify the recipient group ID.").nargs("*");
|
||||
subparser.addArgument("recipient").help("Specify the recipients' phone number.").nargs("*");
|
||||
subparser.addArgument("-u", "--username").help("Specify the recipient username or username link.").nargs("*");
|
||||
subparser.addArgument("--type")
|
||||
.help("Type of message request response")
|
||||
.type(Arguments.enumStringType(MessageRequestResponseType.class))
|
||||
.required(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
final var recipientStrings = ns.<String>getList("recipient");
|
||||
final var groupIdStrings = ns.<String>getList("group-id");
|
||||
final var usernameStrings = ns.<String>getList("username");
|
||||
final var type = ns.<MessageRequestResponseType>get("type");
|
||||
|
||||
final var recipientIdentifiers = CommandUtil.getRecipientIdentifiers(m,
|
||||
false,
|
||||
recipientStrings,
|
||||
groupIdStrings,
|
||||
usernameStrings);
|
||||
m.sendMessageRequestResponse(type == MessageRequestResponseType.ACCEPT ? Type.ACCEPT : Type.DELETE,
|
||||
recipientIdentifiers);
|
||||
}
|
||||
}
|
|
@ -472,6 +472,14 @@ public class DbusManagerImpl implements Manager {
|
|||
return new SendMessageResults(0, Map.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendMessageRequestResponse(
|
||||
final MessageEnvelope.Sync.MessageRequestResponse.Type type,
|
||||
final Set<RecipientIdentifier> recipientIdentifiers
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void hideRecipient(final RecipientIdentifier.Single recipient) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue