Updated JSON RPC service (markdown)

Sebastian Scheibner 2023-08-26 17:41:13 +02:00
parent 30fe6d3856
commit 3cdc268b0e

@ -25,12 +25,22 @@ From the command line:
`echo '{"jsonrpc":"2.0","method":"listGroups","id":"my special mark"}' | signal-cli -u +33123456789 jsonRpc`
Like in dbus daemon mode, messages are automatically received in jsonRpc mode. Incoming messages are sent as JSON-RPC notifications.
## Receiving messages
Like in dbus daemon mode, messages are automatically received in jsonRpc mode (`--receive-mode=automatic`). Incoming messages are sent as JSON-RPC notifications.
Example:
`{"jsonrpc":"2.0","method":"receive","params":{"envelope":{"source":"+33123456789","sourceNumber":"+33123456789","sourceUuid":"uuid","sourceName":"name","sourceDevice":1,"timestamp":1631458508784,"dataMessage":{"timestamp":1631458508784,"message":"foobar","expiresInSeconds":0,"viewOnce":false,"mentions":[],"attachments":[],"contacts":[]}}}}`
In order to not miss messages, automatic receiving of messages can be disabled with the `--receive-mode=manual` parameter.
REQUEST: `{"jsonrpc":"2.0","id":"id","method":"subscribeReceive"}`
RESPONSE: `{"jsonrpc":"2.0","result":0,"id":"id"}`
Messages are then sent similar to the automatic mode, but wrapped in a subscription response object:
`{"jsonrpc":"2.0","method":"receive","params":{"subscription":0,"result":{"envelope":{"source":"+33123456789","sourceNumber":"+33123456789","sourceUuid":"uuid","sourceName":"name","sourceDevice":2,"timestamp":1693064367769,"syncMessage":{"sentMessage":{"destination":"+33123456789","destinationNumber":"+33123456789","destinationUuid":"uuid","timestamp":1693064367769,"message":"j","expiresInSeconds":0,"viewOnce":false}}},"account":"+33123456789"}}}`
## Commands
The commands available for the JSON-RPC mode are the same as the cli commands (except `register`, `verify` and `link`).
The `method` field is the command name and the parameters can be sent as the `params` object.