mirror of
https://github.com/koush/scrypted.git
synced 2026-03-20 16:40:24 +00:00
webhook: fix mixin late init
This commit is contained in:
4
plugins/webhook/package-lock.json
generated
4
plugins/webhook/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/webhook",
|
||||
"version": "0.0.9",
|
||||
"version": "0.0.10",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/webhook",
|
||||
"version": "0.0.9",
|
||||
"version": "0.0.10",
|
||||
"dependencies": {
|
||||
"@types/node": "^16.6.1"
|
||||
},
|
||||
|
||||
@@ -33,5 +33,5 @@
|
||||
"devDependencies": {
|
||||
"@scrypted/sdk": "file:../../sdk"
|
||||
},
|
||||
"version": "0.0.9"
|
||||
"version": "0.0.10"
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class WebhookMixin extends SettingsMixinDeviceBase<Settings> {
|
||||
|
||||
async maybeSendMediaObject(response: HttpResponse, value: any, method: string) {
|
||||
if (!mediaObjectMethods.includes(method)) {
|
||||
response?.send(value.toString());
|
||||
response?.send(value?.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ class WebhookPlugin extends ScryptedDeviceBase implements Settings, MixinProvide
|
||||
const pathSegments = relPath.split('/');
|
||||
const id = pathSegments[1];
|
||||
|
||||
const device = systemManager.getDeviceById<ScryptedDevice>(id);
|
||||
const device = systemManager.getDeviceById<ScryptedDevice & Settings>(id);
|
||||
this.console.log('device', id, device.name);
|
||||
|
||||
if (!device.mixins.includes(this.id)) {
|
||||
@@ -160,6 +160,9 @@ class WebhookPlugin extends ScryptedDeviceBase implements Settings, MixinProvide
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.createdMixins.has(id)) {
|
||||
await device.getSettings();
|
||||
}
|
||||
const mixin = this.createdMixins.get(id);
|
||||
mixin.handle(request, response, device, pathSegments);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user