:quotes.~:
= signal-cli (1)
+:doctype: manpage
== Name
=== uploadStickerPack
-Upload a new sticker pack, consisting of a manifest file and the sticker images.
+Upload a new sticker pack, consisting of a manifest file and the sticker images. +
Images must conform to the following specification: (see https://support.signal.org/hc/en-us/articles/360031836512-Stickers#sticker_reqs )
- Static stickers in PNG or WebP format
If no `-a` account is given, all local accounts will be exported as separate dbus objects under the same bus name.
*--dbus*::
-Export DBus interface on user bus.
-See signal-cli-dbus (5) for info on the dbus interface.
+Export DBus interface on user bus. +
+See **signal-cli-dbus**(5) for info on the dbus interface.
*--dbus-system*::
-Export DBus interface on system bus.
-See signal-cli-dbus (5) for info on the dbus interface.
+Export DBus interface on system bus. +
+See **signal-cli-dbus**(5) for info on the dbus interface.
*--socket [SOCKET]*::
-Export a JSON-RPC interface on a UNIX socket (default $XDG_RUNTIME_DIR/signal-cli/socket).
-See signal-cli-jsonrpc (5) for info on the JSON-RPC interface.
+Export a JSON-RPC interface on a UNIX socket (default $XDG_RUNTIME_DIR/signal-cli/socket). +
+See **signal-cli-jsonrpc**(5) for info on the JSON-RPC interface.
*--tcp [HOST:PORT]*::
-Export a JSON-RPC interface on a TCP socket (default localhost:7583).
-See signal-cli-jsonrpc (5) for info on the JSON-RPC interface.
+Export a JSON-RPC interface on a TCP socket (default localhost:7583). +
+See **signal-cli-jsonrpc**(5) for info on the JSON-RPC interface.
+
+*--http [HOST:PORT]*::
+Expose a JSON-RPC interface as http endpoint (default localhost:8080).
+The JSON-RPC endpoint is `/api/v1/rpc`. +
+See **signal-cli-jsonrpc**(5) for info on the JSON-RPC interface.
*--ignore-attachments*::
Don’t download attachments of received messages.
public void init() throws IOException {
- logger.info("Starting server on " + address.toString());
+ logger.info("Starting server on " + address.toString());
- final var server = HttpServer.create(address, 0);
- server.setExecutor(Executors.newFixedThreadPool(10));
+ final var server = HttpServer.create(address, 0);
+ server.setExecutor(Executors.newFixedThreadPool(10));
- server.createContext("/api/v1/rpc", httpExchange -> {
+ server.createContext("/api/v1/rpc", httpExchange -> {
- if (!"POST".equals(httpExchange.getRequestMethod())) {
- sendResponse(405, null, httpExchange);
- return;
- }
-
- if (!"application/json".equals(httpExchange.getRequestHeaders().getFirst("Content-Type"))) {
- sendResponse(415, null, httpExchange);
- return;
- }
+ if (!"POST".equals(httpExchange.getRequestMethod())) {
+ sendResponse(405, null, httpExchange);
+ return;
+ }
- try {
+ if (!"application/json".equals(httpExchange.getRequestHeaders().getFirst("Content-Type"))) {
+ sendResponse(415, null, httpExchange);
+ return;
+ }
- final Object[] result = {null};
- final var jsonRpcSender = new JsonRpcSender(s -> {
- if (result[0] != null) {
- throw new AssertionError("There should only be a single JSON-RPC response");
- }
+ try {
- result[0] = s;
- });
+ final Object[] result = {null};
+ final var jsonRpcSender = new JsonRpcSender(s -> {
+ if (result[0] != null) {
+ throw new AssertionError("There should only be a single JSON-RPC response");
+ }
- final var jsonRpcReader = new JsonRpcReader(jsonRpcSender, httpExchange.getRequestBody());
- jsonRpcReader.readMessages((method, params) -> commandHandler.handleRequest(objectMapper, method, params),
- response -> logger.debug("Received unexpected response for id {}", response.getId()));
+ result[0] = s;
+ });
- if (result[0] !=null) {
- sendResponse(200, result[0], httpExchange);
- } else {
- sendResponse(201, null, httpExchange);
- }
+ final var jsonRpcReader = new JsonRpcReader(jsonRpcSender, httpExchange.getRequestBody());
+ jsonRpcReader.readMessages((method, params) -> commandHandler.handleRequest(objectMapper,
+ method,
+ params), response -> logger.debug("Received unexpected response for id {}", response.getId()));
+ if (result[0] != null) {
+ sendResponse(200, result[0], httpExchange);
+ } else {
+ sendResponse(201, null, httpExchange);
}
- catch (Throwable aEx) {
- logger.error("Failed to process request.", aEx);
- sendResponse(200, JsonRpcResponse.forError(
- new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
- "An internal server error has occurred.", null), null), httpExchange);
- }
- });
- server.start();
+ } catch (Throwable aEx) {
+ logger.error("Failed to process request.", aEx);
+ sendResponse(200,
+ JsonRpcResponse.forError(new JsonRpcResponse.Error(JsonRpcResponse.Error.INTERNAL_ERROR,
+ "An internal server error has occurred.",
+ null), null),
+ httpExchange);
+ }
+ });
+
+ server.start();
}