@@ -37,12 +37,13 @@ class CoCreateLazyLoader {
37
37
// TODO: return the value so it can be applied directly to modules
38
38
// this.modules[key] = await Config('modules', false, false)
39
39
40
- const config = await Config ( 'modules' , false , false )
41
- if ( ! config )
40
+ this . modules = await Config ( 'modules' , false , false )
41
+ if ( ! this . modules )
42
42
return
43
+ else
44
+ this . modules = this . modules . modules
43
45
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 ) ) {
46
47
this . wsManager . on ( this . modules [ name ] . event , async ( data ) => {
47
48
this . executeScriptWithTimeout ( name , data )
48
49
} ) ;
@@ -73,14 +74,15 @@ class CoCreateLazyLoader {
73
74
} else {
74
75
organization = org . object [ 0 ]
75
76
organizations [ organization . _id ] = organization
76
- hosts [ hostname ] = organization
77
77
}
78
78
}
79
79
80
+ hosts [ hostname ] = organization
81
+
80
82
if ( valideUrl . pathname . startsWith ( '/webhooks/' ) ) {
81
83
let name = req . url . split ( '/' ) [ 2 ] ; // Assuming URL structure is /webhook/name/...
82
84
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 } )
84
86
} else {
85
87
// Handle unknown module or missing webhook method
86
88
res . writeHead ( 404 , { 'Content-Type' : 'application/json' } ) ;
0 commit comments