+ final var subscriptionId = getSubscriptionId(request);
+ if (subscriptionId == null) {
+ unsubscribeReceive(m);
+ } else {
+ if (!unsubscribeReceive(subscriptionId)) {
+ throw new UserErrorException("Unknown subscription id");
+ }
+ }
+ }
+
+ @Override
+ public void handleCommand(
+ final JsonNode request, final MultiAccountManager c, final JsonWriter jsonWriter
+ ) throws CommandException {
+ final var subscriptionId = getSubscriptionId(request);
+ if (subscriptionId == null) {
+ throw new UserErrorException("Missing subscription parameter with subscription id");
+ } else {
+ if (!unsubscribeReceive(subscriptionId)) {
+ throw new UserErrorException("Unknown subscription id");
+ }
+ }
+ }
+
+ private Integer getSubscriptionId(final JsonNode request) {
+ if (request instanceof ArrayNode req) {
+ return req.get(0).asInt();
+ } else if (request instanceof ObjectNode req) {
+ return req.get("subscription").asInt();
+ } else {
+ return null;
+ }