import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.dbus.DbusSignalControlImpl;
import org.asamk.signal.dbus.DbusSignalImpl;
+import org.asamk.signal.http.HttpServerHandler;
import org.asamk.signal.json.JsonReceiveMessageHandler;
import org.asamk.signal.jsonrpc.SignalJsonRpcDispatcherHandler;
import org.asamk.signal.manager.Manager;
.nargs("?")
.setConst("localhost:7583")
.help("Expose a JSON-RPC interface on a TCP socket (default localhost:7583).");
+ subparser.addArgument("--http")
+ .nargs("?")
+ .setConst("localhost:8080")
+ .help("Expose a JSON-RPC interface as http endpoint (default localhost:8080).");
subparser.addArgument("--no-receive-stdout")
.help("Don’t print received messages to stdout.")
.action(Arguments.storeTrue());
subparser.addArgument("--ignore-attachments")
.help("Don’t download attachments of received messages.")
.action(Arguments.storeTrue());
+ subparser.addArgument("--ignore-stories")
+ .help("Don’t receive story messages from the server.")
+ .action(Arguments.storeTrue());
+ subparser.addArgument("--send-read-receipts")
+ .help("Send read receipts for all incoming data messages (in addition to the default delivery receipts)")
+ .action(Arguments.storeTrue());
}
@Override
final var noReceiveStdOut = Boolean.TRUE.equals(ns.getBoolean("no-receive-stdout"));
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
final var ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
+ final var ignoreStories = Boolean.TRUE.equals(ns.getBoolean("ignore-stories"));
+ final var sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
- m.setReceiveConfig(new ReceiveConfig(ignoreAttachments));
+ m.setReceiveConfig(new ReceiveConfig(ignoreAttachments, ignoreStories, sendReadReceipts));
addDefaultReceiveHandler(m, noReceiveStdOut ? null : outputWriter, receiveMode != ReceiveMode.ON_START);
final Channel inheritedChannel;
final var serverChannel = IOUtils.bindSocket(address);
runSocketSingleAccount(m, serverChannel, receiveMode == ReceiveMode.MANUAL);
}
+ final var httpAddress = ns.getString("http");
+ if (httpAddress != null) {
+ final var address = IOUtils.parseInetSocketAddress(httpAddress);
+ final var handler = new HttpServerHandler(address, m);
+ try {
+ handler.init();
+ } catch (IOException ex) {
+ throw new IOErrorException("Failed to initialize HTTP Server", ex);
+ }
+ }
final var isDbusSystem = Boolean.TRUE.equals(ns.getBoolean("dbus-system"));
if (isDbusSystem) {
runDbusSingleAccount(m, true, receiveMode != ReceiveMode.ON_START);
final var noReceiveStdOut = Boolean.TRUE.equals(ns.getBoolean("no-receive-stdout"));
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
final var ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
+ final var ignoreStories = Boolean.TRUE.equals(ns.getBoolean("ignore-stories"));
+ final var sendReadReceipts = Boolean.TRUE.equals(ns.getBoolean("send-read-receipts"));
- final var receiveConfig = new ReceiveConfig(ignoreAttachments);
+ final var receiveConfig = new ReceiveConfig(ignoreAttachments, ignoreStories, sendReadReceipts);
c.getManagers().forEach(m -> {
m.setReceiveConfig(receiveConfig);
addDefaultReceiveHandler(m, noReceiveStdOut ? null : outputWriter, receiveMode != ReceiveMode.ON_START);
final var serverChannel = IOUtils.bindSocket(address);
runSocketMultiAccount(c, serverChannel, receiveMode == ReceiveMode.MANUAL);
}
+ final var httpAddress = ns.getString("http");
+ if (httpAddress != null) {
+ final var address = IOUtils.parseInetSocketAddress(httpAddress);
+ final var handler = new HttpServerHandler(address, c);
+ try {
+ handler.init();
+ } catch (IOException ex) {
+ throw new IOErrorException("Failed to initialize HTTP Server", ex);
+ }
+ }
final var isDbusSystem = Boolean.TRUE.equals(ns.getBoolean("dbus-system"));
if (isDbusSystem) {
runDbusMultiAccount(c, receiveMode != ReceiveMode.ON_START, true);