Skip to content

Commit 7839c7f

Browse files
committed
fix: this.modules
1 parent bc219f0 commit 7839c7f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/server.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ class CoCreateLazyLoader {
3737
// TODO: return the value so it can be applied directly to modules
3838
// this.modules[key] = await Config('modules', false, false)
3939

40-
const config = await Config('modules', false, false)
41-
if (!config)
40+
this.modules = await Config('modules', false, false)
41+
if (!this.modules)
4242
return
43+
else
44+
this.modules = this.modules.modules
4345

44-
for (let name of Object.keys(config.modules)) {
45-
this.modules[name] = config.modules[name];
46+
for (let name of Object.keys(this.modules)) {
4647
this.wsManager.on(this.modules[name].event, async (data) => {
4748
this.executeScriptWithTimeout(name, data)
4849
});
@@ -73,14 +74,15 @@ class CoCreateLazyLoader {
7374
} else {
7475
organization = org.object[0]
7576
organizations[organization._id] = organization
76-
hosts[hostname] = organization
7777
}
7878
}
7979

80+
hosts[hostname] = organization
81+
8082
if (valideUrl.pathname.startsWith('/webhooks/')) {
8183
let name = req.url.split('/')[2]; // Assuming URL structure is /webhook/name/...
8284
if (this.modules[name]) {
83-
this.executeScriptWithTimeout(name, { req, res, crud: this.crud, organization, valideUrl })
85+
this.executeScriptWithTimeout(name, { req, res, crud: this.crud, organization, valideUrl, organization_id: data.organization })
8486
} else {
8587
// Handle unknown module or missing webhook method
8688
res.writeHead(404, { 'Content-Type': 'application/json' });

0 commit comments

Comments
 (0)