Merge branch 'main' of github.com:koush/scrypted

This commit is contained in:
Koushik Dutta
2023-02-14 11:05:34 -08:00
2 changed files with 15 additions and 4 deletions

View File

@@ -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 /mnt/sda/video path on the host
# to the /nvr path inside the docker container.
# - /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:

View File

@@ -112,7 +112,16 @@ class WebhookMixin extends SettingsMixinDeviceBase<Settings> {
}
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<Settings> {
}
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();
export default new WebhookPlugin();