mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
parent
c8daef5113
commit
a7a5947a1b
2 changed files with 79 additions and 15 deletions
|
@ -8,6 +8,7 @@ import org.asamk.signal.OutputType;
|
|||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.jsonrpc.SignalJsonRpcDispatcherHandler;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.MultiAccountManager;
|
||||
import org.asamk.signal.manager.api.ReceiveConfig;
|
||||
import org.asamk.signal.output.JsonWriter;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
|
@ -19,7 +20,7 @@ import java.io.InputStreamReader;
|
|||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class JsonRpcDispatcherCommand implements LocalCommand {
|
||||
public class JsonRpcDispatcherCommand implements LocalCommand, MultiLocalCommand {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(JsonRpcDispatcherCommand.class);
|
||||
|
||||
|
@ -68,6 +69,24 @@ public class JsonRpcDispatcherCommand implements LocalCommand {
|
|||
handler.handleConnection(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
|
||||
final var receiveConfig = getReceiveConfig(ns);
|
||||
c.getManagers().forEach(m -> m.setReceiveConfig(receiveConfig));
|
||||
c.addOnManagerAddedHandler(m -> m.setReceiveConfig(receiveConfig));
|
||||
|
||||
final var jsonOutputWriter = (JsonWriter) outputWriter;
|
||||
final var lineSupplier = getLineSupplier();
|
||||
|
||||
final var handler = new SignalJsonRpcDispatcherHandler(jsonOutputWriter,
|
||||
lineSupplier,
|
||||
receiveMode == ReceiveMode.MANUAL);
|
||||
handler.handleConnection(c);
|
||||
}
|
||||
|
||||
private static ReceiveConfig getReceiveConfig(final Namespace ns) {
|
||||
final var ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
|
||||
final var ignoreStories = Boolean.TRUE.equals(ns.getBoolean("ignore-stories"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue