Adapt receive subscription notification to have payload in result field

This commit is contained in:
AsamK 2023-08-11 00:35:48 +02:00
parent 6cbd583746
commit b51c791629
2 changed files with 9 additions and 4 deletions

View file

@ -3,6 +3,11 @@
## [Unreleased]
**Attention**: Now requires native libsignal-client version 0.30.0
### Breaking changes
- Adapt receive subscription notification in JSON-RPC to have payload in result field
- Before: `{"jsonrpc":"2.0","method":"receive","params":{"envelope":{ ... },"account":"+XXX","subscription":0}}`
- After: `{"jsonrpc":"2.0","method":"receive","params":{"subscription":0,"result":{"envelope":{ ... },"account":"+XXX"}}}`
### Added
- Manage identities via DBus (Thanks @bublath)
- Added support for SVR2 PINs

View file

@ -4,7 +4,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ContainerNode;
import com.fasterxml.jackson.databind.node.IntNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
@ -86,8 +85,9 @@ public class SignalJsonRpcDispatcherHandler {
final var subscriptionId = nextSubscriptionId.getAndIncrement();
final var handlers = managers.stream().map(m -> {
final var receiveMessageHandler = new JsonReceiveMessageHandler(m, s -> {
final ContainerNode<?> params = objectMapper.valueToTree(s);
((ObjectNode) params).set("subscription", IntNode.valueOf(subscriptionId));
final var params = new ObjectNode(objectMapper.getNodeFactory());
params.set("subscription", IntNode.valueOf(subscriptionId));
params.set("result", objectMapper.valueToTree(s));
final var jsonRpcRequest = JsonRpcRequest.forNotification("receive", params, null);
try {
jsonRpcSender.sendRequest(jsonRpcRequest);