From f0a09b4869204a11baa15de689080d8e66a8ac6d Mon Sep 17 00:00:00 2001 From: Grzegorz Zdanowski Date: Tue, 14 Feb 2023 11:03:04 -0600 Subject: [PATCH 1/3] Add JSON output for webhook methods calls (#554) --- plugins/webhook/src/main.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/webhook/src/main.ts b/plugins/webhook/src/main.ts index 4e2f0fbdf..bb2366243 100644 --- a/plugins/webhook/src/main.ts +++ b/plugins/webhook/src/main.ts @@ -112,7 +112,16 @@ class WebhookMixin extends SettingsMixinDeviceBase { } const result = await device[methodOrProperty](...parameters); - this.maybeSendMediaObject(response, result, methodOrProperty); + if (request.headers['accept']?.includes('application/json')) { + response?.send(JSON.stringify({ result }), { + headers: { + 'Content-Type': 'application/json', + } + }); + } + else { + this.maybeSendMediaObject(response, result, methodOrProperty); + } } catch (e) { this.console.error('webhook action error', e); @@ -123,7 +132,7 @@ class WebhookMixin extends SettingsMixinDeviceBase { } else if (allInterfaceProperties.includes(methodOrProperty)) { const value = device[methodOrProperty]; - if (request.headers['accept'] && request.headers['accept'].indexOf('application/json') !== -1) { + if (request.headers['accept']?.includes('application/json')) { response?.send(JSON.stringify({ value }), { headers: { 'Content-Type': 'application/json', @@ -215,4 +224,4 @@ class WebhookPlugin extends ScryptedDeviceBase implements Settings, MixinProvide } } -export default new WebhookPlugin(); \ No newline at end of file +export default new WebhookPlugin(); From 6ff44d31b7ac0a8da63a8352ea10fc083583ce99 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Tue, 14 Feb 2023 10:18:09 -0800 Subject: [PATCH 2/3] Update docker-compose.yml --- docker/docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index e3cda66f8..27c8cf8fd 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -23,7 +23,9 @@ services: volumes: - ~/.scrypted/volume:/server/volume # modify and add the additional volume for Scrypted NVR - # - /media/external:/media/external + # the following example would mount the /media/external path on the host + # to the /nvr path inside the docker container. + # - /media/external:/nvr # logging is noisy and will unnecessarily wear on flash storage. # scrypted has per device in memory logging that is preferred. logging: From c2ccf0fc515521ade97130dcca1ace415ae709a3 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Tue, 14 Feb 2023 10:23:22 -0800 Subject: [PATCH 3/3] Update docker-compose.yml --- docker/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 27c8cf8fd..c72d2bbe8 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -23,9 +23,9 @@ services: volumes: - ~/.scrypted/volume:/server/volume # modify and add the additional volume for Scrypted NVR - # the following example would mount the /media/external path on the host + # the following example would mount the /mnt/sda/video path on the host # to the /nvr path inside the docker container. - # - /media/external:/nvr + # - /mnt/sda/video:/nvr # logging is noisy and will unnecessarily wear on flash storage. # scrypted has per device in memory logging that is preferred. logging: