[jsonapi] Make PUT /api/outputs/x capable of device verification

This commit is contained in:
ejurgensen 2020-05-26 22:46:49 +02:00
parent 18e75c2445
commit d18e49f59b
2 changed files with 10 additions and 1 deletions

View File

@ -317,7 +317,7 @@ curl -X PUT "http://localhost:3689/api/player/seek?seek_ms=-30000"
| GET | [/api/outputs](#get-a-list-of-available-outputs) | Get a list of available outputs | | GET | [/api/outputs](#get-a-list-of-available-outputs) | Get a list of available outputs |
| PUT | [/api/outputs/set](#set-enabled-outputs) | Set enabled outputs | | PUT | [/api/outputs/set](#set-enabled-outputs) | Set enabled outputs |
| GET | [/api/outputs/{id}](#get-an-output) | Get an output | | GET | [/api/outputs/{id}](#get-an-output) | Get an output |
| PUT | [/api/outputs/{id}](#change-an-output) | Change an output (enable/disable or volume) | | PUT | [/api/outputs/{id}](#change-an-output) | Change an output setting |
| PUT | [/api/outputs/{id}/toggle](#toggle-an-output) | Enable or disable an output, depending on the current state | | PUT | [/api/outputs/{id}/toggle](#toggle-an-output) | Enable or disable an output, depending on the current state |
@ -482,6 +482,7 @@ PUT /api/outputs/{id}
| --------------- | --------- | -------------------- | | --------------- | --------- | -------------------- |
| selected | boolean | *(Optional)* `true` to enable and `false` to disable the output | | selected | boolean | *(Optional)* `true` to enable and `false` to disable the output |
| volume | integer | *(Optional)* Volume in percent (0 - 100) | | volume | integer | *(Optional)* Volume in percent (0 - 100) |
| pin | string | *(Optional)* PIN for device verification |
**Response** **Response**

View File

@ -1530,6 +1530,7 @@ jsonapi_reply_outputs_put_byid(struct httpd_request *hreq)
json_object* request; json_object* request;
bool selected; bool selected;
int volume; int volume;
const char *pin;
int ret; int ret;
ret = safe_atou64(hreq->uri_parsed->path_parts[2], &output_id); ret = safe_atou64(hreq->uri_parsed->path_parts[2], &output_id);
@ -1566,6 +1567,13 @@ jsonapi_reply_outputs_put_byid(struct httpd_request *hreq)
ret = player_volume_setabs_speaker(output_id, volume); ret = player_volume_setabs_speaker(output_id, volume);
} }
if (ret == 0 && jparse_contains_key(request, "pin", json_type_string))
{
pin = jparse_str_from_obj(request, "pin");
if (pin)
ret = player_speaker_authorize(output_id, pin);
}
jparse_free(request); jparse_free(request);
if (ret < 0) if (ret < 0)